Check if queue is empty and wait a bit until checking again.

Avoids high CPU usage caused by the while loop.
Do not add null message to list. Avoids NPE.