The queue is thread-safe in both modes. TheDequeue()method ensures thread-safety by writing it in a way that does not depend on possible instruction reordering on the CPU. TheEnqueue()method uses an atomic compare-and-swap in multiple-producers scenarios.