Changed the work thread to only sleep when queue is empty