Skip to main content

Posts

Showing posts from 2024

About virtual thread in java

In this blog post, I will introduce you to the concept of virtual threads in Java and how they can improve the performance and scalability of your applications that rely on networking I/O. Virtual threads are lightweight threads that reduce the effort of writing, maintaining, and debugging high-throughput concurrent applications. They are instances of java.lang.Thread that are not tied to a specific operating system (OS) thread, but rather run on a small number of OS threads managed by the Java runtime. This allows the Java runtime to suspend and resume virtual threads when they perform blocking I/O operations, freeing up the OS threads for other tasks. Virtual threads typically have a shallow call stack and perform as few as a single HTTP client call or a single JDBC query. They are suitable for tasks that spend most of their time waiting for I/O, but not for long-running CPU-intensive tasks. Virtual threads are supported by the Java Platform since Java SE 21. They are part of Project