线程
实现
public class Main {
static class T extends Thread{
public T(String name) {
super(name);
}
@Override
public void run() {
while(true){
try {
currentThread().sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(111);
}
}
}
public static void main(String[] args) throws InterruptedException {
T t = new T("test---001");
//t.setDaemon(true);
t.start();
Thread.currentThread().sleep(5000);
System.out.println("over");
}
}
Last updated