Replaces AtomicBoolean and spin logic with Mutex.