Use an AtomicBoolean to be safe with all the threads involved