Results 1 to 4 of 4
  1. #1
    avirit1983 is offline Member
    Join Date
    Nov 2010
    Posts
    2
    Rep Power
    0

    Default 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.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by avirit1983 View Post
    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.
    Thanks for posting your assignment, but please understand that no one here is going to do this for you. If you have an actual question, then by all means ask it, but please also show us the work you've done so far as well.

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,368
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by avirit1983 View Post
    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.
    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,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    Join Date
    Dec 2010
    Posts
    22
    Rep Power
    0

    Default

    Quote Originally Posted by avirit1983 View Post
    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.
    Classic problem about Producer and Consumers and synchronization of threads. Search that on google and you will find a solution

Similar Threads

  1. MultiThreading Problem part 2
    By ravjot28 in forum New To Java
    Replies: 33
    Last Post: 03-11-2010, 06:22 PM
  2. MultiThreading Problem
    By ravjot28 in forum New To Java
    Replies: 8
    Last Post: 03-02-2010, 12:23 PM
  3. Multithreading in java
    By MuslimCoder in forum New To Java
    Replies: 5
    Last Post: 02-20-2010, 08:16 PM
  4. Log 4j Multithreading
    By joe2010 in forum Threads and Synchronization
    Replies: 1
    Last Post: 01-31-2010, 03:48 AM
  5. problem using ObjectOutputStream in multithreading
    By sanjeevbindroo in forum Networking
    Replies: 3
    Last Post: 10-15-2009, 08:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •