Label t; int k=1200; Timer timer;
MyTimer(){ this.setLayout(null); this.setBounds(200, 200, 300, 100); t=new Label(); t.setBounds(50, 50, 100, 30);
}
}
import java.awt.*; import java.awt.event.*;
类的子类的对象
Public class Test{ public void static main(String[] args){ MyThread mt=new MyThread(); }
} class MyThread extends Thread{
}
线程
2.运行:
一个Thread类的子类需要重写run()方法,而run() 方法中的内容, 就是线程运行时执行的程序。执行线程的start方法,则线程开始运行。
Label t; int k=1200; Timer timer; MyTimer(){
this.setLayout(null); this.setBounds(200, 200, 300, 100);
}
}
import java.awt.*; import java.awt.event.*;
public class MyTimer extends Frame implements ActionListener {
启动线程的程序如下:看看会有什么效果
public class Example { public static void main(String[] args) { Visit v=new Visit(); Thread a=new Thread(v);Thread b=new Thread(v);Thread c=new Thread(v); Thread d=new Thread(v);Thread e=new Thread(v); a.start();b.start();c.start();d.start();e.start(); try {