Blocking queue and multi-threaded consumer, how to know when to stop
I have a single thread producer which creates some task objects which are then added into an ArrayBlockingQueue (which is of fixed size). I also start a multi-threaded consumer. This is build as a fixed thread pool ( Executors.newFixedThreadPool(threadCount); ). I then submit some ConsumerWorker intances to this threadPool, each ConsumerWorker having a refference to the above mentioned ArrayBlockingQueue instance. Each such Worker will do a take() on the queue and deal with the task. My issue is, what's the best way to have a Worker know when there won't be any more work to be done. In other