On 01/12/2025 22:38, Stig Rohde Døssing wrote:
:
If the main thread is only sent a single interrupt, then by the time
ExecutorService.close is called, the main thread will no longer be
interrupted, since that flag is cleared when the InterruptedException
is thrown.
Right, in the example, the interrupted status is cleared by Future::get
when it throws InterruptedException, and the translation of
try-with-resources means the close method does not have a reference to
the "pending exception".
In general, cancellation and shutdown is difficult topic, and a big
motivation for the StructuredTaskScope API.
-Alan