Produce pro = new Produce(cp);
Consume con = new Consume(cp);
Thread t1 = new Thread(pro);
Thread t2 = new Thread(pro);
Thread t3 = new Thread(con);
Thread t4 = new Thread(con);
t1.start();
t2.start();
t3.start();
t4.start();
比
//new Thread(new Produce(cp)).start();
//new Thread(new Produce(cp)).start();
//new Thread(new Consume(cp)).start();
//new Thread(new Consume(cp)).start(); |