Project Loom: Modern Scalable Concurrency for the Java Platform

Java · 13K views · 2020 · 38:35

Open on YouTube

C, C++, Rust, Go & systems languagesSoftware architecture & designSoftware performance & optimizationtalkdated

Why Stack Overflow recommends it

Stack Overflow users link it when explaining Project Loom, virtual threads, and how blocking code can scale, as an authoritative talk from one of Loom's designers.

Recommended by 3 people across 3 different months, 2020 to 2022.

What it is

A 2020 talk by Ron Pressler of Oracle introducing Project Loom, which adds lightweight virtual threads to the Java platform. It explains why heavyweight threads limit scalable server code and how Loom restores the thread as the unit of concurrency while keeping debugging and profiling tools working.

What people said

Recommends Matias Bjarland · 2020-12 · Stack Overflow · on “How the use threads in groovy to iterate 0.4 million records”

I did a similar test using groovy a while back. I did one million sleep 500ms in my test in 10 seconds using the virtual thread executor. Essentially ignoring context switching etc this is 50k concurrent threads. Agree, it is a quantum leap, but it is believable since this is the whole point of the new fibers implementation and in loom, one thread no longer maps to one os thread, they are light weight and managed by the jvm. A good video from one of the people involved in implementing loom: [this video]

Recommends Basil Bourque · 2021-01 · Stack Overflow · on “Java run loop with CompletableFuture”

The Answer by Stephen C [LINK] looks correct, and is appropriate for today's Java. But in the future (ahhh, see what I did there?), Java may offer a simpler and much faster approach, with virtual threads. Project Loom Project Loom [LINK] is coming to Java, with preliminary builds available now [LINK] built on early-access Java 16. One major feature is virtual threads ( fibers [LINK] ). These are lightweight threads. When the flow-of-control in any virtual thread blocks, Java detects the block and switches in another virtual thread to keep the CPU core busy. This can massively speed up threaded code that frequently blocks (as opposed to strictly CPU-bound tasks like video-encoding). Note that

Recommends Janez Kuhar · 2021-11 · Stack Overflow · on “Will Project Loom Virtual Threads improve the perfomance of parallel Streams?”

IIUC, the real benefit of a virtual thread is when you have a blocking I/O operation. With Loom, the underlying *carrier thread* will continue executing other tasks while your virtual thread blocks. Before Loom, this distinction was not made - there was only one type of threads - and the blocking I/O was not a feasible option for high throughput applications, like web servers. You might find this presentation [this video] helpful.

Cites Tao Chen · 2022-02 · Stack Overflow · on “What's the resizable stack of JVM virtual threads?”

The open jdk project "Loom" supports virtual thread which allows the classic IO-blocking API to enjoy the great benefits of async, reactor, coroutine development styles. I searched it on youtube, I learned that the most important magic of virtual thread is the "resizable stack" in this video [this video] . [LINK] That's why millions of virtual threads can be created and blocked. I am very interested in how the "resizable stack" is implemented. Is it a contiguous memory segment or a discontinuous linked list structure? Is its performance high enough? Function can be called by both platform threads and virtual threads. Will there be a performance penalty due to the need to determine what situation