Re:Project Loom and Structured Concurrency
by pbourke on Friday December 04, 2020 @08:07AM
(#25301817)
To summarize: up till now, Java Threads have been 1:1 with OS threads. They’re limited to a few thousand per JVM. This project moves to an M:N threading model but retains the Thread API. It allows for millions of threads per JVM and async/await style performance of the existing synchronous Java libraries without language changes and with minimal changes to the standard library.
[ Parent
| on HN ]
Re:Project Loom and Structured Concurrency
by gpderetta on Friday December 04, 2020 @08:17AM
(#25301902)
Originally (about 20 years ago) java threads were M:N I think. How is this different? If I had to guess, they are not opaque to the VM which has more freedom to optimize them.
Re:Project Loom and Structured Concurrency
by simiones on Friday December 04, 2020 @08:24AM
(#25301962)
This is mentioned in the article: the old green threads model was not blocking aware - if a green thread scheduled on an OS thread issued a blocking call (say a listen on a socket) than the whole OS thread was blocked.
With Project Loom, if a virtual thread executes a blocking call, the virtual thread is suspended and the OS thread is free to execute another virtual thread.
Re:Project Loom and Structured Concurrency
by anonymousDan on Friday December 04, 2020 @11:42AM
(#25304402)
So how does it actually execute the system call under the hood? Using some kind of background OS thread pool?
Re:Project Loom and Structured Concurrency
by Cojen on Friday December 04, 2020 @12:20PM
(#25305025)
From what I can tell, async system calls are used whenever possible. A blocking call on a socket doesn't make a blocking system call, thus permitting the carrier OS thread to go do something else. As for file I/O, things are a bit messy. Older linux kernels don't support "true" async file I/O, and the Java NIO async file channels do use thread pools to emulate async behavior in that case.