Make queue structure thread-safe