home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-03-21 | 1.1 KB | 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)
- {
- }
- }
- }
- }
-
-