ProdCons1 pc = new ProdCons1();
System.out.println("Ready (p to produce, c to consume):");
int i;
while ((i = System.in.read()) != -1) {
char ch = (char)i;
switch(ch) {
case 'p": pc.produce(); break;
case 'c": pc.consume(); break;
}
}
protected void
produce()
int len = 0;
synchronized(list) {
Object justProduced = new Object();
list.addFirst(justProduced);
len = list.size();
list.notifyAll();
}
System.out.println("List size now " + len);