home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java by Example
/
jbecd.bin
/
JBE-CD
/
NTUsers
/
JBECODE.ZIP
/
JavaByExample
/
chap31
/
MyThread2.java
< prev
next >
Wrap
Text File
|
1996-03-21
|
1KB
|
58 lines
public class MyThread2 extends Thread
{
ThreadApplet3 applet;
boolean forward;
int count;
int increment;
int end;
int position;
MyThread2(ThreadApplet3 applet, boolean forward)
{
this.applet = applet;
this.forward = forward;
}
public void run()
{
InitCounter();
DoCount();
}
protected void InitCounter()
{
if (forward)
{
count = 0;
increment = 1;
end = 1000;
position = 120;
}
else
{
count = 1000;
increment = -1;
end = 0;
position = 180;
}
}
protected void DoCount()
{
while (count != end)
{
count = count + increment;
String str = String.valueOf(count);
applet.SetDisplayStr(str, position);
try
sleep(100);
catch (InterruptedException e)
{
}
}
}
}