public class TestThreadaLive {
public static void main(String[] args) {
SubThread sbt = new SubThread();
Thread tr = new Thread(sbt);
tr.start();
for(int i = 0; i < 50; i++){
System.out.println("Main Thread:" + i);
}
}
}
class SubThread implements Runnable{
public void run(){
System.out.println(Thread.currentThread().isAlive());
for(int i = 0; i < 100; i++){
System.out.println(Thread.currentThread().isAlive());
System.out.println("SubThread is Still alive? " + i);
}
}
}
Toy Program:线程 alive
最新推荐文章于 2022-11-26 23:22:22 发布