进程状态:
1.new----->新生状态
2.start------->就绪状态
3.cpu调用------->运行状态
4.外部干涉(加入标志位)------->死亡状态
5.sleep------>.阻塞状态
package cn.mb.thread;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
- sleeep模拟倒计时
- @author 骚彬
/
public class BlockSleep01 {
public static void main(String[] args) throws InterruptedException {
// 倒计时
Date endTime=new Date(System.currentTimeMillis()+100010);
long end=endTime.getTime();
while(true) {
System.out.println(new SimpleDateFormat(“mm:ss”).format(endTime) );
Thread.sleep(1000);
endTime=new Date(endTime.getTime()-1000);
if(end-1000>endTime.getTime()) {
break;
}
}
}
public static void test( ) throws InterruptedException {
//倒数10个数,1秒1个
int num=10;
while(true) {
Thread.sleep(1000);
System.out.println(num–);
}
}
}