Running 10 Millions Threads in 7 Seconds | Java Virtual Threads

Published: 19 August 2023
on channel: Made Easy
1,007
44

Full Video Link :    • Understanding Java Virtual Threads | ...  

What is a Virtual Thread?
Like a platform thread, a virtual thread is also an instance of java.lang.Thread. However, a virtual thread isn't tied to a specific OS thread. A virtual thread still runs code on an OS thread. However, when code running in a virtual thread calls a blocking I/O operation, the Java runtime suspends the virtual thread until it can be resumed. The OS thread associated with the suspended virtual thread is now free to perform operations for other virtual threads.

Virtual threads are implemented in a similar way to virtual memory. To simulate a lot of memory, an operating system maps a large virtual address space to a limited amount of RAM. Similarly, to simulate a lot of threads, the Java runtime maps a large number of virtual threads to a small number of OS threads. Unlike platform threads, virtual threads typically have a shallow call stack, performing as few as a single HTTP client call or a single JDBC query. Although virtual threads support thread-local variables, you should carefully consider using them because a single JVM might support millions of virtual threads. Virtual threads are suitable for running tasks that spend most of the time blocked, often waiting for I/O operations to complete. However, they aren't intended for long-running CPU-intensive operations.

JEP : https://openjdk.org/jeps/444
OpenJDK : https://openjdk.org/

Tags : #java #openjdk #jdk20 #jdk21 #jdk19 #java #javabasics #javaconcepts #javaprogramming #javamultithreading #javainterviewquestions


On this page of the site you can watch the video online Running 10 Millions Threads in 7 Seconds | Java Virtual Threads with a duration of hours minute second in good quality, which was uploaded by the user Made Easy 19 August 2023, share the link with friends and acquaintances, this video has already been watched 1,007 times on youtube and it was liked by 44 viewers. Enjoy your viewing!