package com.gxx.threads.study.test6; /** * 测试类-测试getId()、isAlive()和sleep() * @author Gxx */ public class Test { /** * main方法 * @param args */ public static void main(String[] args) { System.out.println("main主线程 开始 时间=" + System.currentTimeMillis()); System.out.println("main主线程 getId()=" + Thread.currentThread().getId()); MyThread thread = new MyThread(); System.out.println("线程 start前 isAlive()=" + thread.isAlive()); thread.start(); System.out.println("线程 start后 isAlive()=" + thread.isAlive()); System.out.println("main主线程 结束 时间=" + System.currentTimeMillis()); try { Thread.sleep(1000); System.out.println("main主线程 sleep(1秒)后 线程 isAlive=" + thread.isAlive()); } catch (InterruptedException e) { e.printStackTrace(); } } }