Thread类中对 interrupt()、interrupted()、isInterrupted()、start()、join() 、yield() 方法的理解

Thread thread = new Thread();

// 给线程设置一个中断标记
thread.interrupt();
// 判断线程是否有中断标记
thread.isInterrupted();
// 开启线程
thread.start();
// 让thread加入到主线程,并使主线程阻塞住
thread.join();


// 让当前线程中断
Thread.interrupted();
// 让当前线程把cpu时间让出来,然后再和其他线程一起争抢cpu
Thread.yield();
posted @ 2020-11-18 18:31  孔乙己的茴香豆  阅读(115)  评论(0编辑  收藏  举报