多线程 生产,消费 ProducerConsumerDemo
ProducerConsumerDemo.java
/**
* 资源类
*/
class ShareData {
private int number = 0;
private Lock lock = new ReentrantLock();
private Condition condition = lock.newCondition();
public void increment() {
lock.lock(); //加锁
//1
原创
2020-12-03 16:37:39 ·
247 阅读 ·
0 评论