fix race condition in initialization of queue