Use a ReentrantLock instead of an AtomicBoolean