
164
Chapter 10: Threads []
24
25
26
27
28
29
30
31
32
33
34
35
repaint () ;
public void paint(Graphics g) {
g.drawString(text, xpos, ypos) ;
}
public void stop() {
numbersThread = null;
}
ThreadForEver
The code for the corresponding HTML page, ThreadYorEver.html, can be found on the
book's Web site. The applet implements a Runnable interface in the same manner as a finite
applet thread. There is also no change to the applet start method. However, instead of a finite
for loop in the run method, we specify the following while loop (line 18):
while (numbersThread != null) {
As long as the thread is not stopped, this condition ...