turn num; Р } Р Р public void setNum(int num) Р { Р this.num = num; Р } Р Р public Storage getStorage() Р { Р return storage; Р } Р Р public void setStorage(Storage storage) Р { Р this.storage = storage; Р } Р} Рpublic class Test Р{ Р public static void main(String[] args) Р { Р // 仓库对象Р Storage storage = new Storage(); Р // 生产者对象Р Producer p1 = new Producer(storage); Р Producer p2 = new Producer(storage); Р Producer p3 = new Producer(storage); Р Producer p4 = new Producer(storage); Р Producer p5 = new Producer(storage); Р Producer p6 = new Producer(storage); Р Producer p7 = new Producer(storage); Р // 消费者对象Р Consumer c1 = new Consumer(storage); Р Consumer c2 = new Consumer(storage); Р Consumer c3 = new Consumer(storage); Р Р // 设置生产者产品生产数量Р p1.setNum(10); Р p2.setNum(10); Р p3.setNum(10);