If there is nothing else done in your main thread but the receiving and processing of messages from the queue, you can just blocking wait for new messages.
If you cannot blocking wait, transfer the wait logic to a runnable implementing inner class (e.g. QueueWorker
), that is executed by a worker thread inside your main class.