make queue thread safe