Cancelling a sleeping fiber

Alan Bateman Alan.Bateman at oracle.com
Tue Nov 6 07:23:41 UTC 2018


On 06/11/2018 06:54, Fabio Tudone wrote:
> Hi, am I correct that currently "java.lang.Fiber"'s "cancel" method doesn't
> interrupt a sleeping fiber and that currently the only way to do that is
> interrupting the corresponding shadow thread?
> Is it meant to be like this (in this case I suggest to document it in the
> JavaDoc though) or will there be something like a "cancel(boolean
> canInterrupt)" overload in the future?
>
> Also, currently the "CompletableFuture" returned by scheduling a "Callable"
> doesn't seem to cancel nor interrupt the underlying fiber itself: I think
> this too should be either changed or clarified in the JavaDoc.
>
There are several pieces to cancellation that are not in the loom repo 
at this time, mostly because there are issues with how it interacts with 
Thread interruption, InterruptibleChannel and all the spec issues that 
flow from that. So TBD, and yes, cancelling the a Future will need to 
forward the cancel to the scheduled fiber too.

-Alan


More information about the loom-dev mailing list