Early Access Loom Builds

Alan Bateman Alan.Bateman at oracle.com
Thu Aug 1 01:26:03 UTC 2019


On 30/07/2019 23:47, Dávid Karnok wrote:
> Okay, I see.
>
> My next question is about FiberScope then.
>
> If I understand correctly, FiberScope.close blocks if run in a 
> traditional thread and suspends if run in a Fiber. Thus opening a 
> scope with try() in the main method will block the main thread (i.e., 
> down to the OS level) until the execution falls out of try() and close 
> is called, right?
Yes, close will block until all fibers scheduled in the scope have 
terminated.

>
> Now if I have code that runs on a single-threaded ExecutorService, a 
> FiberScope still appears to block the underlying OS thread until try() 
> finishes:
There aren't any fibers in your example. Can you change it the following 
to satisfy yourself that you can use your single thread executor for fibers:

try (var scope = FiberScope.open()) {
     scope.schedule(exec, task);
}

-Alan


More information about the loom-dev mailing list