Implemented timed waiting and unconditional pop for queue.