Home » Core Java » Producer Consumer Design Pattern

Producer Consumer Design Pattern

Producer Consumer Design Pattern is one of the most frequently asked questions in interviews.Basically 4 to 15 year experience guys are being asked this
question.Believe me if you can answer this question correctly ,you are almost going to crack the interview.

Real Time Scenarios :
When you go to restaurant to have food,you have a table and food menus.The restaurant person take your orders and put all those on your table.
You wait till the waiter has not put food on your table and the waiter waits till you finish you food.The waiter can not put extra food until you are finish
and you can not eat until he puts food on the table.So you and waiter depends on eachother. The.The waiter(producer) produces and you the consumer consumes.
You can also think until a bowler does not bowl a batsman can not bat and until the batsman is not ready ,the bowler can not bowl.

Program ::
ProducerConsumer Main class :



Output ::

Leave a comment

Your email address will not be published. Required fields are marked *

2 × two =