Trendovi i budućnost Jave
-
-
30'
Thread-per-request mode is the most common model in Java server-side programming today; however, this model is used mostly for I/O operation who often block the threads that are executing them, which is costly and limits the maximum number of requests. Developers could always solve this with an asynchronous programming model; on the other hand, this model is complicated and hard to debug. The ideal situation would be to have an efficiency of asynchronous programming and be able to program in usual, sequential order. That is where Virtual Threads introduced by Project Loom come in. Virtual Threads, formally known as Fibers, are created and managed by the JVM and only mapped to OS threads when they need to perform a specific task. This makes their creation, blocking, and spawning cheap. They also support the java.lang.Thread API, so developers would not even notice the difference (most of the time). In this presentation we will present how you can use Virtual Threads, compare them with OS threads, and show many potential benefits of such an approach.