Toy Program:线程 alive

来源:互联网 发布:php eval返回值 编辑:程序博客网 时间:2024/04/29 09:35
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);}}}

0 0
原创粉丝点击