摘要: sleep 存在异常InterruptedException 每一个对象都有一把锁,sleep不会释放锁。 (线程同步) 1.模拟延时 try{ Thread.sleep(millis:100); }catch(InterruptedException e){ e.printStackTrace() 阅读全文
posted @ 2022-06-26 18:36 小布丁dd 阅读(17) 评论(0) 推荐(0)
摘要: 1.建议线程自己正常停止 > 利用次数,不建议死循环。 2.设置标志位 > 3.不用stop destory 方法。 public class TestStop implements Runnable{ //1. 设置标志位 prviate boolean flag= true; public vo 阅读全文
posted @ 2022-06-26 18:12 小布丁dd 阅读(30) 评论(0) 推荐(0)