5 producers baking cookies.
When at least 50 units in stock
then they inform the 2 consumers.
Consumers clear the stock.
When 100 units in stock, production stops
- use wait()/notify() concept
- use graphical output (applet/awt/swing)
You didn't say what your problems are
I don't think it is a good idea to start the thread itself in its constructor
Your for loop inside Producer iterate 101 times instead of 100
Your consumers should take those items from the stock?
When you have consumers clear the stock, "100 units in stock" should exclude those consumed?
Where did you use notify?
I would add a display for the consumers, showing how many cookies they took. Also, I think I would have a display for produces and consumers showing the totals I would change the RIP to Stop or Quit. In the display to the console, you should add one to the producer number so that it matches the screen (5 instead of 4). It seems like you have the producer printing the total number of cookies after 50, but the produces should notify the consumer and the consumer should start taking cookies. This would reduce the number of cookies the producer has, except that there are 5 producers and only 2 consumers. Try this example.
Here's another attempt
1) Producers start right away, but stop when the total production reaches 100
2) Consumers start after there are 50 cookies, but stop when there are zero cookies.
3) Cntrl-C doesn't work.