3 ms·
In the examples with structured concurrency. The point of using an executor service is not to reuse the threads. But instead to control their termination. If yo
by kasperni 6y ago
In the examples with structured concurrency. The point of using an executor service is not to reuse the threads. But instead to control their termination. If you read Nathaniel J. Smith's primer [1] on structured concurrency. The ExecutorService in the examples act as the nursery. Loom is just being "lazy" and reusing ExecutorService for something that it wasn't originally intended to do. Earlier versions had a specific class called FiberScope [2]. Whether or not we will see more specialised classes for this in the future I don't know.
[1] https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/ https://vorpus.org/blog/notes-on-structured-concurrency-or-g...
[2] https://www.javaadvent.com/2019/12/project-loom.html https://www.javaadvent.com/2019/12/project-loom.html