Author blog (Jose Paumard): http://blog.paumard.org/en/
GOLDEN RULE IN CONCURRENT PROGRAMMING
Never expose to outside the lock object
you use to synchronize your code!!!
private volatile Thread blinker;
public void stop() {
blinker = null;
}
public void run() {
Thread thisThread = Thread.currentThread();
while (blinker == thisThread) {
try {
Thread.sleep(interval);
} catch (InterruptedException e){
}
repaint();
}
}