home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Component;
- import java.awt.Font;
- import java.awt.Graphics;
-
- public class ThreadApplet3 extends Applet {
- MyThread2 thread1;
- MyThread2 thread2;
- String displayStr;
- Font font;
- int position;
-
- public void init() {
- this.font = new Font("TimesRoman", 0, 72);
- ((Component)this).setFont(this.font);
- this.displayStr = "";
- this.position = 120;
- this.thread1 = new MyThread2(this, true);
- this.thread2 = new MyThread2(this, false);
- }
-
- public void start() {
- if (this.thread1.isAlive()) {
- this.thread1.resume();
- } else {
- this.thread1.start();
- }
-
- if (this.thread2.isAlive()) {
- this.thread2.resume();
- } else {
- this.thread2.start();
- }
- }
-
- public void stop() {
- this.thread1.suspend();
- this.thread2.suspend();
- }
-
- public void destroy() {
- this.thread1.stop();
- this.thread2.stop();
- }
-
- public void paint(Graphics var1) {
- var1.drawString(this.displayStr, 50, this.position);
- }
-
- public synchronized void SetDisplayStr(String var1, int var2) {
- this.displayStr = var1;
- this.position = var2;
- ((Component)this).repaint();
- }
- }
-