-
Book Overview & Buying
-
Table Of Contents
Java Coding Problems - Second Edition
By :
Java allows us to write multithreaded applications via the java.lang.Thread class. These are classical Java threads that are basically just thin wrappers of OS (kernel) threads. As you’ll see, these classical Java threads are referred to as platform threads, and they have been available for quite a long time (since JDK 1.1, as the following diagram reveals):

Figure 10.4: JDK multithreading evolution
Next, let’s move on to JDK 19 virtual threads.
OS threads are expensive in every single way, or more specifically, they are costly in terms of time and space. Creating OS threads is, therefore, a costly operation that requires a lot of stack space (around 20 megabytes) to store their context, Java call stacks, and additional resources. Moreover, the OS thread scheduler is responsible for scheduling Java threads, which is another costly operation that requires moving...