After a quiet period the batch size and queue size might be empty thus ending the while loop but some new message had a chance to be added to the queue before the flag was set.
Thus calling the stop() method from a different thread than the one calling process was not threadsafe!
...e
After a quiet period the batch size and queue size might be empty thus ending the while loop but some new message had a chance to be added to the queue before the flag was set. Thus calling the stop() method from a different thread than the one calling process was not threadsafe!