packagecom.thread;publicclassTestState{publicstaticvoidmain(String[] args)throwsInterruptedException{Thread thread =newThread(()->{for(int i =0; i <5; i++){try{Thread.sleep(1000);}catch(InterruptedException e){
e.printStackTrace();}}System.out.println("111111111111");});Thread.State state = thread.getState();System.out.println(state);
thread.start();
state = thread.getState();//更新线程状态System.out.println(state);while(state !=Thread.State.TERMINATED){//只要线程不终止 就一直执行Thread.sleep(1000);
state = thread.getState();System.out.println(state);}}}