Currently the logic for the Dispatcher can be simplified as follows:
while (msg =_queue.take() != null)
Stop if required
There are a couple of problems, the first is that if the _queue is not empty when the stop request is made then the dispatcher will remove a message from _queue and sit in the Stop until it is restarted, where it will then process the message.
The second issue is that if the queue is empty when the stop is requested then nothing happens... until a message is received and the dispatcher then removes it and holds it in the Stop.
Finally. there is no way to stop the dispatcher once it has made the take() call, other than via an interrupt() call.
Changes to the dispatcher should be done to allow it to be stopped and started with validation i.e. thread A calls dispatcher.stop() and that does not return until the dispatcher has stopped. Currently it is a request that is never confirmed.
In providing this functionality we will be able to avoid the interrupt() call that has already been identified as in need of addressing see