Figure 3


Getting a thread to voluntarily stop execution.

Thread 1: Thread 2:
thread2.stopRequested = true; while (!stopRequested) {
// do a little work
}