[concurrency-interest] Queue with interrupt

Chris Hegarty chris.hegarty at oracle.com
Thu May 18 07:43:25 EDT 2017


> On 17 May 2017, at 10:29, David Holmes <davidcholmes at aapt.net.au> wrote:
> 
> ...
> If there are tasks in the queue then the worker is not waiting for new tasks to do - so you've changed your requirements. You would need a deque to allow sentinel tasks to be forced to the head of the queue.

I’ve always wished that we could somehow squeeze a sentinel into the
implementation in order to provide a “CloseableBlockingQueue” with a
blocking takeOrNull(), or similarly named, method. Rather than folk having
to roll their own.

-Chris.



More information about the Concurrency-interest mailing list