package theard;
public class MyThread1 extends Thread {
static int num=0;
public static void main(String args[])
{
Thread t= Thread.currentThread();
System.out.println("主线程是: "+t.getName());
System.out.println("--------------");
MyThread1 ex = new MyThread1();
ex.start();
MyThread1 ex2 = new MyThread1();
ex2.start();
MyThread1 ex3 = new MyThread1();
ex3.start();
MyThread1 ex4 = new MyThread1();
ex4.start();
MyThread1 ex5 = new MyThread1();
ex5.start();
}
public void run() {
System.out.println("子线程是:"+this);
System.out.println("do something:"+num++);
System.out.println("--------------");
}
}
线程理解二
最新推荐文章于 2022-09-28 21:20:49 发布