Added a flag indicating that no more tests will be queued. Also implemented thread-safety, and blocking in enqueue,dequeue, and peak