[concurrency-interest] Fork and and timed get

Doug Lea dl at cs.oswego.edu
Wed Nov 27 14:01:43 EST 2013

On 11/27/2013 11:09 AM, Romain Colle wrote:

> The basic idea here is that, as far as I can tell, the get(long timeout,
> TimeUnit unit) method of a ForkJoinTask does not respect the Future contract.

Well, it does meet spec in that it times out no earlier than required.

> Before blocking and waiting for the task to complete, the timed get() method
> tries to either steal and execute the task, or at least help it complete.
> If it succeeds doing so, it will for instance execute the task that it is
> waiting for. And in this case, there is no telling how long it will take to
> execute it ...

Yes. Given the documentation of FJ, people ought to expect this
and would claim it to be a bug if it did otherwise. Maybe we
should add better method documentation for timed get, and also
explain a few ways to get non-participatory timeouts.
For example, creating a new thread to perform the invocation
and timing out on Thread.join. Suggestions welcome.


More information about the Concurrency-interest mailing list