Specifications
Sun Services
Java™ Programming Language
Module 13, slide 10 of 37
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
Terminating a Thread
1 public class Runner implements Runnable {
2 private boolean timeToQuit=false;
3
4 public void run() {
5 while ( ! timeToQuit ) {
6 // continue doing work
7 }
8 // clean up before run() ends
9 }
10
11 public void stopRunning() {
12 timeToQuit=true;
13 }
14 }










