Skip to content

sanman-shelar/java-virtual-threads-demo

Repository files navigation

Java Virtual Threads Demo

Basic example to demonstrate the working of Platform and Virtual Threads.

More details around threads can be found here

Requirements

  • JDK 21
  • You can use any compatible IDE or CLI to compile and execute the program

Diagram

Virtual Threads

Scenarios

  • NonVirtualThreadDemo uses Platform Thread to demonstrate the blocking nature of Thread execution
  • VirtualThreadDemo uses Virtual Thread to demonstrate the mounting and unmounting of Threads

Profiling for 10,000 Threads

Program is ran by setting MAX_THREADS to 10000 within the code and enabling Profile on Application Startup through JVM config.

NonVirtualThreadDemo Non Virtual Threads


VirtualThreadDemo Virtual Threads

About

Demo project to showcase virtual threads

Topics

Resources

License

Stars

Watchers

Forks

Languages