Early Access Loom Builds

Dávid Karnok akarnokd at gmail.com
Thu Aug 1 10:37:02 UTC 2019


Thanks, I figured out since then to use FiberScope.background() which
doesn't need (or works with) try-with-resources.

Alan Bateman <Alan.Bateman at oracle.com> ezt írta (időpont: 2019. aug. 1.,
Cs, 3:28):

> 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
>


-- 
Best regards,
David Karnok


More information about the loom-dev mailing list