Remove race conditions in priority queue push and pop