Thread创建线程
public class main{
public static void main(String[] args){
A a = new A();
a.start();
int i = 0;
while (i<=80){
System.out.println(Thread.currentThread().getName()+i);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
i++;
}
}
}
class A extends Thread{
@Override//方法的重写
public void run() {
while (true){
System.out.println("当前的线程为:"+Thread.currentThread().getName());
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}