线程中sleep()方法(静态方法)与interrupt()方法(非静态方法)

sleep(long time):调用此方法的线程将会处于睡眠状态,它还是具有CPU执行权的,只不过程序在此停留,超时后,该线程又回到就绪状态,如果被打断,会出现编译时异常InterruptedException。

interrupt():如若线程调用此方法会中断该线程中阻塞状态。

猜你喜欢

转载自blog.csdn.net/Betty_betty_betty/article/details/82144023