C# vs Java: .NET 10 Native AOT and Java Virtual Threads Solve Different Problems

Native AOT and virtual threads are not rivals: Native AOT compiles a .NET app ahead of time for faster startup and a smaller memory footprint, and Microsoft says the benefit is greatest when many instances are deployed, while Java’s virtual threads are aimed at code that blocks on I/O. As of 12 November 2026 Java 25 is the current LTS on Oracle’s support roadmap (JDK 27 is a non-LTS release), and the Azure Functions table lists .NET 10 through 14 November 2028, so this guide sets .NET 10 against Java 25 and adds a Native AOT limits checklist, a concurrency sizing rule and three measurements to take on your own service.

Native AOT helps when a service runs as many instances that each must start and hold memory; virtual threads help when many requests spend most of their time waiting.

Google · Preferred Sources

Don't miss new tech stories on Google

Add Tech Insider once in the Google app and our stories appear in your news suggestions.

Add Now

Pairing .NET 10 with Java 25, and where JDK 27 and .NET 11 fit

JDK 27 reached General Availability on 15 September 2026 and is the Reference Implementation of Java SE 27, according to the OpenJDK JDK 27 page. Oracle’s Java SE support roadmap lists Java SE 8, 11, 17, 21 and 25 as LTS releases and names Java 29 in September 2027 as the next planned one, so 27 is not an LTS. Java 25 was released on 16 September 2025 and is described on its OpenJDK JDK 25 page as a long-term-support release from most vendors.

If you deploy JDK 27, note the patch deadline. The current update is 27.0.1.0.3, dated 24 October 2026, and Oracle’s release notes recommend against using it after the next critical patch update, scheduled for 17 November 2026.

On Microsoft’s side, the Azure Functions supported-languages table lists .NET 8 and .NET 9 through 10 November 2026, both already past as of 12 November 2026, and .NET 10 through 14 November 2028. Going by that table, new Functions projects belong on .NET 10. Microsoft’s .NET support policy page, checked on 12 November 2026, also lists .NET 11 as released on 10 November 2026 (version 11.0.0, STS, supported to 14 November 2028), so a team that tracks every release on both sides can compare JDK 27 with .NET 11. On the language side, Microsoft’s C# 14 page says C# 14 is supported on .NET 10.

The practical rule: if you will move to each new release as it ships, compare JDK 27 with .NET 11. If you want Java’s long-term-support line, set Java 25 against .NET 10, with Java 29 as the next planned LTS step.

What Native AOT removes, and the documented limits that decide whether you can use it

Microsoft’s Native AOT documentation says these apps start faster, have smaller memory footprints, and can run on machines that don’t have the .NET runtime installed. Because no JIT compiler runs while the app is running, they also suit locked-down environments that forbid one. The same page says the payoff is largest for workloads that run very many instances, for example cloud infrastructure and hyper-scale services. A single long-lived service with a handful of replicas sits at the other end of that range.

Enabling it is one property. Microsoft says setting PublishAot in the project file switches on Native AOT compilation at publish time and also runs code-usage analysis while you build and edit, so the warnings appear before you ship. The project file and script below publish for Linux into a temporary directory, print its size and clean up even if the publish fails: set -eu stops on the first error or unset variable, and the trap removes the directory on exit.

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
    <PublishAot>true</PublishAot>
    <VerifyReferenceAotCompatibility>true</VerifyReferenceAotCompatibility>
  </PropertyGroup>
</Project>
#!/bin/sh
set -eu

OUT="$(mktemp -d)"
trap 'rm -rf "$OUT"' EXIT

dotnet publish -c Release -r linux-x64 -o "$OUT"
du -sh "$OUT"

Two platform rules apply to what that script produces. Native AOT binaries are platform-specific: Microsoft says a Linux-built binary runs only on that Linux version or newer, so one built on Ubuntu 20.04 runs on 20.04 and later but not on 18.04. Debug information is kept in a separate file by default (.dbg, .pdb or .dSYM depending on platform), and setting StripSymbols to false on Unix-like platforms embeds it and makes the binary larger.

The limits below come from the same Microsoft page. They decide go or no-go before any startup figure does, because a blocked feature means a rewrite.

Documented limitWhat it breaksHow to check your codebase
No dynamic loading, for example Assembly.LoadFilePlugin and add-in designs that load assemblies at run timeSearch for assembly-loading calls in your code and in the packages you ship
No runtime code generation, for example System.Reflection.EmitLibraries that emit IL at run timePublish with the analyzers on and read the warnings per package
System.Linq.Expressions always uses its interpreted formNothing fails, but expression trees run slower than runtime-generated compiled codeFind hot paths that compile expression trees, often inside mappers and data-access layers
Trimming is requiredCode that reflects over types the trimmer cannot see staticallyTreat every trim warning as a possible run-time failure
All generic struct instantiations are pre-generatedDisk size can grow significantlyCompare the published size with your current deployment size
No C++/CLI; on Windows, no built-in COMMixed-mode and COM-based componentsList native and interop dependencies before choosing the target OS
Runtime libraries are not all fully annotated; some ASP.NET Core features are unsupportedSome warnings are not actionable by you, and some framework features are unavailableList the ASP.NET Core features you use and try each one under Native AOT before committing
Libraries need AOT annotations; IsAotCompatible metadata is new in .NET 10Packages built for earlier .NET versions carry no such metadataSet VerifyReferenceAotCompatibility (opt-in) to get warning IL3058 for references without it; libraries should target net8.0 or later to get AOT analysis warnings
Android support is experimental, with no built-in Java interopNative AOT on Android as a production targetCheck the target platform list before planning mobile reuse

Java’s closest counterpart is GraalVM Native Image, and its metadata documentation states that Native Image requires all classes to be known at build time (a “closed-world assumption”). That is a constraint of the same family as the dynamic-loading limit in the first row above, so a plugin-style design has to be checked against it on the Java side too. Teams weighing a different compiled language for the same kind of service can read our Rust vs Go comparison.

Virtual threads: blocking code at scale, and what Oracle says they will not do

Oracle’s JDK 27 virtual threads guide defines the limits plainly:

“Virtual threads are not faster threads; they do not run code any faster than platform threads.”

Oracle, Java SE 27 core libraries guide

The guide says they exist to provide scale (higher throughput), not speed (lower latency). They fit tasks that are mostly blocked, typically on I/O, and are not intended for long-running CPU-intensive operations. When code in a virtual thread calls a blocking I/O operation, the Java runtime suspends the virtual thread and the OS thread it was using is free for other virtual threads. That is how a large number of virtual threads is mapped onto a small number of OS threads. The Thread API documentation adds that a single JVM may support millions of virtual threads.

Version matters before any tuning. JEP 444 finalizes virtual threads in JDK 21, with changes from JDK 20 informed by developer feedback. Of the LTS lines on Oracle’s roadmap (8, 11, 17, 21 and 25), 21 is the first that has them as a final feature, so a service still on 17 has to move before this section applies to it.

Four tunables and caveats from the Oracle pages matter when you size a service. The scheduler’s parallelism defaults to the number of available processors, and its maximum pool size defaults to 256 platform threads. Pinning happens when a virtual thread is executing a native method or a foreign function; Oracle says it does not make an application incorrect, though it can limit scalability. Virtual threads are daemon threads with a fixed priority that cannot be changed. And Executors can create an executor service that starts a new virtual thread for each task, which is a direct way to move an existing blocking service over.

The two styles look like this. C# writes each wait as an await; Java keeps the blocking call and lets the runtime suspend it:

// C#: every wait is an await, all the way up the call chain
public async Task<User> GetUserAsync(int id)
{
    var response = await _httpClient.GetAsync($"/users/{id}");
    var json = await response.Content.ReadAsStringAsync();
    return JsonSerializer.Deserialize<User>(json);
}

// Java: plain blocking code, one virtual thread per task
User getUser(int id) throws Exception {
    var request = HttpRequest.newBuilder(URI.create(baseUrl + "/users/" + id)).build();
    var response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
    return objectMapper.readValue(response.body(), User.class);
}

List<User> getUsers(List<Integer> ids) throws Exception {
    try (var executor = Executors.newVirtualThreadPerTaskExecutor()) {
        var futures = ids.stream()
            .map(id -> executor.submit(() -> getUser(id)))
            .toList();
        var users = new ArrayList<User>();
        for (var f : futures) users.add(f.get());
        return users;
    }
}

Per the JDK 27 feature list, Structured Concurrency (JEP 533) is in its seventh preview and Lazy Constants (JEP 531) in its third, so neither is a stable part of a fan-out design yet. On pauses, Oracle’s JDK 23 significant-changes page lists JEP 474, which made generational mode the default for ZGC from JDK 23. The tail-latency measurement in the protocol below is how to see what that means on your own heap.

Sizing concurrency: in-flight requests equal request rate times wait

A service’s concurrency is set by how fast requests arrive and how long each one waits, so a documented ceiling says little about your service until you put your own rate and wait through this formula. The table after it shows how the result moves when either input changes:

requests in flight = requests per second x seconds each request spends waiting

Change to the inputsEffect on requests in flight
Request rate doubles, wait unchangedDoubles
Wait per request doubles, rate unchangedDoubles
Rate and wait both doubleQuadruples
Rate halves while wait doublesUnchanged

The table is arithmetic on the formula, not a measurement: each row multiplies one or both inputs by the stated factor. Oracle’s statement that a JVM may support millions of virtual threads describes what the runtime can hold. It is not a cross-language benchmark, and whether your own rate times wait comes anywhere near that ceiling is something only your own figures can show. The limit worth checking first may well be downstream, in the database connection pool or a remote service’s rate limit, because every in-flight request is waiting on something. Virtual threads also do not speed up a CPU-bound handler, since Oracle says they are not faster threads and the scheduler’s parallelism defaults to the processor count.

The rule applies to both languages, because it depends on rate and wait, not on syntax. C# expresses the wait with await and Java with a blocking call; what each runtime costs per waiting request comes from measuring your own service.

Startup, memory and cost per instance: three numbers to record on your own service

Microsoft’s documentation gives the direction of the Native AOT effect (faster startup, smaller footprint, no JIT at run time), and the JDK 27 feature list includes two changes on the JVM side: compact object headers by default (JEP 534) and G1 as the default collector in all environments (JEP 523). The figures for your service come from three measurements:

MeasureHow to take itHold constant
Time to first requestClock from process start to the first successful HTTP responseSame container CPU and memory limits, same host
Resident memory after warm-upRead it after N identical requests, with N large enough that the Java JIT has settledSame request mix, same JDK and .NET build flags, recorded
Tail latency and in-flight count at a fixed request rateDrive both services at the same rate and log one high percentile (the same one for both) and the peak requests in flightSame load generator, same downstream database and pool sizes

Turn the memory result into money with your own prices: monthly difference = instances x (memory per instance on option A minus option B, in GB) x price per GB-hour x hours billed. The formula only matters at scale, which matches Microsoft’s statement that Native AOT pays off most for workloads with many deployed instances. With a few replicas the difference is small whichever way it falls.

Platform support, licences and ecosystem signals that apply to the choice

TopicDocumented factSource
.NET MAUI targetsChecked 12 November 2026, the newer tab lists iOS 12.2 or higher, macOS 12 or higher via Mac Catalyst, and Windows 11 and Windows 10 version 1809 or higher via WinUI 3; apps targeting .NET 11 need Android API 24 or higherMicrosoft, .NET MAUI supported platforms
.NET licenceMicrosoft’s open-source page says the .NET repositories typically use the MIT or Apache 2 licensesMicrosoft, .NET open source
OpenJDK licenceGPLv2 with the Classpath ExceptionOpenJDK, licence text
Oracle JDK 27 licenceChecked 12 November 2026: Oracle JDK for the six-month releases (Java 26 through 28) is under the Oracle No-Fee Terms and Conditions License; Oracle OpenJDK builds are GPLv2+CPEOracle, Java SE JDK FAQs
JDK 27 binariesProduction-ready binaries under the GPL from Oracle; binaries from other vendors follow shortlyOpenJDK, JDK 27 page
Amazon CorrettoAWS describes Corretto as a no-cost, multiplatform, production-ready distribution of the OpenJDKAWS, Amazon Corretto documentation
Java on AndroidGoogle announced at Google I/O 2019 that Android development will be increasingly Kotlin-first, and says it has stood by that commitmentAndroid Developers, Kotlin-first
Language popularityThe TIOBE index page lists C# as its Language of the Year winner for 2025 and for 2023TIOBE index
Hiring demandChecked 12 November 2026: Itransition’s statistics page ranks Java third among languages recruiters seek, at 39.5% of recruiters, and lists C# at 24.4%; its in-demand languages page ranks C# 6th by recruiter demand (24.4%)Itransition, software development statistics; Itransition, in-demand programming languages

Read the Oracle rows together: the GPL binaries the OpenJDK page mentions are Oracle’s OpenJDK builds, while Oracle JDK itself carries the No-Fee Terms and Conditions License, and Corretto is another OpenJDK distribution, so check which download your build pipeline pulls. On the .NET side the licence is MIT or Apache 2 for the repositories Microsoft refers to, which leaves the Java download as the licence question to settle. MAUI covers mobile and desktop clients from C#, while Android Native AOT is still experimental; for Java on Android, Google’s stated direction is increasingly Kotlin-first. The TIOBE and Itransition rows are market signals about languages, not measures of either runtime: the hiring figures say Java skills are asked for by a larger share of recruiters than C# skills, which bears on staffing, not on whether Native AOT or virtual threads fit your service.

Matching each workload to the feature that pays for it

The table keys each workload to the single documented fact from the vendors’ pages that decides it.

WorkloadDecided byFirst check
Scale-to-zero functions, many small instancesMicrosoft: Native AOT benefit is greatest at high instance counts, and it runs where a JIT is disallowedWalk the Native AOT limits table against your dependencies
Blocking I/O fan-out over JDBC or HTTPOracle: blocking calls suspend the virtual thread and free the OS threadConfirm the service runs on Java 21 or later, then look for pinning on native and foreign calls and check the size of the downstream pool
CPU-bound computationOracle: virtual threads are not for long-running CPU-intensive work and run no faster than platform threadsNeither feature helps; profile the algorithm instead
Reflection-, plugin- or Emit-heavy frameworksMicrosoft: no dynamic loading and no Reflection.Emit under Native AOT; GraalVM: Native Image needs all classes known at build timeStay on the regular runtime unless the analyzers come back clean
Pause-sensitive servicesOracle: generational ZGC is the default mode since JDK 23 (JEP 474); G1 is the default collector in all environments in JDK 27 (JEP 523)Run the tail-latency measurement from the protocol on your own heap
Long support windowSee the pairing section for the LTS and support datesPair .NET 10 with Java 25, and choose 27 only if you will track every release
Cross-platform client appsMicrosoft: MAUI targets Android, iOS, macOS and Windows; Android Native AOT is experimentalCompare the target list with the devices you must support
Moving a service between stacksWaits are written as await in C# and as blocking calls in JavaMove one service first and compare the three measurements

Moving from Java to C# means turning blocking call chains into awaited ones; moving from C# to Java lets those chains stay blocking when they run on a virtual-thread-per-task executor.

The controller layer is where the two stacks look most alike. The same lookup endpoint in Spring and in ASP.NET Core:

// Java (Spring)
@RestController
@RequestMapping("/users")
public class UserController {
    private UserService userService;

    public UserController(UserService userService) {
        this.userService = userService;
    }

    @GetMapping("/{id}")
    public ResponseEntity<User> getUser(@PathVariable int id) {
        return ResponseEntity.ok(userService.findById(id));
    }
}

// C# (ASP.NET Core)
[ApiController]
[Route("users")]
public class UsersController : ControllerBase
{
    private readonly IUserService _userService;

    public UsersController(IUserService userService)
    {
        _userService = userService;
    }

    [HttpGet("{id}")]
    public ActionResult<User> GetUser(int id)
    {
        return _userService.FindById(id);
    }
}

The Java version can stay as written when the service behind it blocks on a virtual thread; on the C# side, a service that does I/O would make this action awaited, as in the earlier snippet. For cross-platform client work, our Flutter vs React Native comparison covers the non-.NET options.

To start, add PublishAot to your service project and IsAotCompatible to your libraries, run the analyzers and count the remaining warnings. Then run one staging Java service, on Java 21 or later, on a virtual-thread-per-task executor under the same load as its current version and compare the three measurements above.

Nadia Dubois

Nadia Dubois

AI, software and the business of tech

Nadia Dubois covers AI, software and the business of tech for Tech Insider: AI models and the products built on them, developer and productivity software, pricing, and the company decisions and regulation that shape the industry.

View all articles