摘要: 1. Exchanger 用于线程之间的数据交换 //生产者生产出固定的数量后与消费者的产品容器进行交换 class Producer implements Runnable{ private Queue<String> products; private Exchanger<Queue> exch 阅读全文
posted @ 2021-06-29 11:09 一穷三白 阅读(62) 评论(0) 推荐(0)
摘要: 1. CountDownLatch 用于线程计时,完成操作后通过countDownLatch.countDown() 就能让计时减一,直到计时为零之后,执行countDownLatch.await() 后的代码,否则阻塞。 1 class MainThread implements Runnable 阅读全文
posted @ 2021-06-29 10:06 一穷三白 阅读(131) 评论(0) 推荐(0)