Methods that do not modify class data are only thread-safe if the object is never modified by any method. Otherwise, the method of another thread could change the object (under a lock, correctly), and a call queue::empty()in your thread without acquiring a lock can lead to a race condition (depending on its implementation).
source
share