Thread vs Tasks

Eric Kolotyluk eric at kolotyluk.net
Thu Nov 18 17:32:05 UTC 2021


Sorry if this is repeated, but for some reason, posting from Microsoft
Windows 10 Mail does not seem to get to the list, but Gmail does?

From
StructuredExecutor.html#fork(java.util.concurrent.Callable,java.util.function.BiConsumer)
<Fromhttps://download.java.net/java/early_access/loom/docs/api/java.base/java/util/concurrent/StructuredExecutor.html#fork(java.util.concurrent.Callable,java.util.function.BiConsumer)>



"Starts a new thread in this executor to run the given task and an
operation to run when the task completes."



In my mind, I am trying to separate the concept of Thread vs Task. Is this
saying that there is always a 1:1 correspondence between Thread and Task,
that StructuredExecutor only spawns Threads?



I was under the impression with Executor operations, such as ForkJoinPool,
that there was a 1:many relationship between Worker Threads and Tasks,
where each worker could handle many Tasks. Am I misunderstanding this?



Indeed, it may be that for Virtual Threads it makes sense to implement a
1:1 relationship, but StructuredExecutor also supports Platform Threads,
and such a 1:1 relationship might be horrible.



Cheers, Eric


More information about the loom-dev mailing list