Thread safety for the queue (incomplete)