[concurrency-interest] Is LinkedBlockingQueue.isEmpty() thread safe?

Szabolcs Ferenczi szabolcs.ferenczi at gmail.com
Fri Apr 20 07:27:07 EDT 2007

On 20/04/07, Kasper Nielsen <kasper at kav.dk> wrote:
> Yes it is thread safe. And what exactly makes you wonder if it isn't?

I was wondering whether it was planned to be used in a multi-threading
environment. Now, although it is thread safe in the sense that it does
not brake anything in the shared data structure, it is a useless
method for a data structure that is designed to be used by concurrent
threads. You can query whether it is empty, but you cannot do anything
with the result. Either isEmpty() yields true or false, anything can
be the case. The queue can even be full at the very time the isEmpty
returns true.

So we can conclude this method on LBQ is something that can be
classified as YAGNI.

Can anyone show a meaningful use of that query in a multithreading environment?

Best Regards,

More information about the Concurrency-interest mailing list