Knowing when we've exceeded our deadline

Alan Bateman Alan.Bateman at oracle.com
Tue May 4 11:36:16 UTC 2021


On 03/05/2021 20:26, Dr Heinz M. Kabutz wrote:
> Hi,
>
> in older versions of Project Loom, we could guess whether our 
> ExecutorService had exceeded our timeout, because the calling thread 
> would exit interrupted. Not sure if this was deliberate or a side 
> effect. However, in the latest build, the owner thread does not return 
> interrupted. What would be a good way to know whether we have exceeded 
> our deadline or not?

We've flip flopped a bit on this topic, the reason is that it's a 
helpful in some usages, a hindrance in others.  As an example, suppose 
the main/owner thread is blocked in Future.get, invokeAny, or invokeAll 
when the deadline is reached. The thread executor will be (forcefully) 
shutdown and this will interrupt its threads. Assuming the tasks react 
to interrupt then the main thread will wakeup. If the main/owner thread 
is additionally interrupted then it could be problematic and also racy 
as the outstanding tasks will completely (abnormally) at around the same 
time. So for now at least, it's simple deadline that shuts down the 
thread executor, nothing more. We will need to come back to this topic 
again when we finally get to structured concurrency.

-Alan


More information about the loom-dev mailing list