...
Code Block | ||
---|---|---|
| ||
final class ControlledStop implements Runnable { private volatile boolean done = false; // ... @Override public void run() { //... } // ... } |
The volatile flag establishes a happens-before relationship between this thread and any other thread that sets done
.
...