Core concept
volatile boolean stopped = false;
// visible to other threads immediatelyAdvertisement
How it works
Doesn't prevent compound ops races. Use AtomicX for that.
Advertisement
Trade-offs + gotchas
Simple flags. Double-checked locking.