现有如下代码:
package cn.itcast.thread.pc;
public class Test {
public static void main(String[] args) {
BaoZiGui bzg = new BaoZiGui();
Thread t1 = new Thread(new GuKe(bzg), "gk1");
Thread t2 = new Thread(new ChuShi(bzg), "cs1");
Thread t3 = new Thread(new GuKe(bzg), "gk2");
Thread t4 = new Thread(new ChuShi(bzg), "cs2");
private String name=null;
private final Lock lock=new ReentrantLock();
private final Condition con1=lock.newCondition();
private final Condition con2=lock.newCondition();
private boolean flag=false;
private int count=0;//用于统计生产消费的商品总数
private int cnt1=0; //用于存储生产商品数
private int cnt2=0;//用于存储消费商品数
private int thread1=0;//存储开启的生产线程数
private int thread2=0;//存储开启的消费线程数
public static void main(String[] args) {
MultiThreadShareData mtsd= new MultiThreadShareData();
mtsd.proAndCon(4, 5, 100);