Results 1 to 4 of 4
Thread: Java Multithreading Problem
- 11-27-2010, 06:43 PM #1
Member
- Join Date
- Nov 2010
- Posts
- 2
- Rep Power
- 0
Java Multithreading Problem
Write a java program which simulates the below scenario.
In bakery backer is preparing bread continuously and put breads into stock, every customer is buying a packet of bread, if bread is not in stock customer will wait till he/she gets the packet of bread.
Note:
I. Every customer gets one packet of bread.
II. Use multithreading system.
III. Program shows stocks of bread, every customer’s status
IV. Pass number of customers, speed of the baker in milliseconds to bake bread as argument from command line.
-
- 11-27-2010, 07:16 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,406
- Blog Entries
- 7
- Rep Power
- 17
As a rule of thumb: everything should synchronize on the shared resource, here: the stock. So both a baker and a consumer should synchronize on it, a baker should wait for the condition where s/he can put a bread in the stock and consumre should wait until a bread is available in the stock. It depends on the stock whether or not it can contain more than one bread or maybe can even contain unlimited amounts of bread. No matter what, the bakers should synchronize on the stock in case a consumer is taking away one bread from it. Another hint: I answered another thread about producers/consumers and even supplied Java code; search for it.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 12-03-2010, 10:18 PM #4
Member
- Join Date
- Dec 2010
- Posts
- 22
- Rep Power
- 0
Similar Threads
-
MultiThreading Problem part 2
By ravjot28 in forum New To JavaReplies: 33Last Post: 03-11-2010, 06:22 PM -
MultiThreading Problem
By ravjot28 in forum New To JavaReplies: 8Last Post: 03-02-2010, 12:23 PM -
Multithreading in java
By MuslimCoder in forum New To JavaReplies: 5Last Post: 02-20-2010, 08:16 PM -
Log 4j Multithreading
By joe2010 in forum Threads and SynchronizationReplies: 1Last Post: 01-31-2010, 03:48 AM -
problem using ObjectOutputStream in multithreading
By sanjeevbindroo in forum NetworkingReplies: 3Last Post: 10-15-2009, 08:00 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks