Sensing Interruptions
- Thread could occasionally call
Thread.currentThread().isInterrupted()
- sleep, wait throw InterruptedException
when thread interrupted
- . . . and then the interruption status is cleared!
- More robust: Sleep occasionally, catch exception and react to
interruption
- Recommendation: Terminate run when sensing interruption