Thread vs Tasks

Eric Kolotyluk eric at kolotyluk.net
Thu Nov 18 22:13:09 UTC 2021


Sorry, forgot to reply to all

thought Tasks were observable and manageable via their Futures?

Okay, if StructuredExecutor is like ThreadPerTaskExecutor, then that makes
sense to me. This allows for the possibility of other types of
StructuredExecutor in the future...

Instead of creating a new type of Executor, why not create another object
that is passed to the Executor as a parameter, the way the ThreadFactory is
passed. For example, via a SessionFactory, where one of the Session types
is StructuredSession, then all Executors could be extended with Structured
Concurrency.

Then we could have something like

var virtualThreadFactory = Thread.ofVirtual.factory()
var structuredSession = Executors.newStructuredSession(. . .)
var structuredExecutor =
Executors.newThreadPerTaskExecutor(virtualTheadFactory, structuredSession)

In this way, Structured Concurrency is more applicable to more contexts...
not that you need to implement it for all contexts now... maybe just
.newThreadPerTaskExecutor() for now...

Also, .fork() and .join() would be session methods, not executor methods...

This introduced two new concepts, Sessions, and Structured Sessions...

Just thinking out loud again...

Cheers, Eric


More information about the loom-dev mailing list