Results 1 to 2 of 2
  1. #1
    kkid is offline Senior Member
    Join Date
    Jul 2012
    Posts
    240
    Rep Power
    3

    Default Concurrent processing - 6 threads sharing resources - wait() and notify()

    I am writing a program based on the dining philosophers problem using just wait() and notify() and, as I have never done concurrent processing before, I want to make sure that I am heading in the right direction with what I am doing.

    If you don't know, the dining philosophers problem states that there are 6 people around a table with 6 pieces of cutlery in between them (1 to the left and 1 to the right of each person). Two people cannot use the same piece at the same time and both pieces are required for the person to eat. I have to ensure that each person gets a chance to eat (has both pieces at the same time) and each person gets a chance to think (has none). We can't have a person going too long without a piece as they will starve.


    Back to my program:

    Do I need to make pairs of the people either side of a piece of cutlery, then as one person picks up this piece, the wait() method is called on the other thread (person) to halt it until the other person has finished eating where he will then call notify() to wake up the other thread and let that person pick up the cutlery?

    I haven't done any concurrent processing, as I said, so don't know how I link these two threads together. I have seen some mention of "synchronise" on tutorials I have attempted, is that what I need. Also, I am struggling to see a way of doing this for 6 threads (people) simultaneously (Do I just do lots of overlapping synchronisation pairs?).

    Can somebody point me in the right direction on how to start or on some good tutorials (Not the orcale one, I have gone through this) that will be helpful for this situation?

    Thank you.

  2. #2
    jashburn is offline Senior Member
    Join Date
    Feb 2014
    Posts
    219
    Rep Power
    1

    Default Re: Concurrent processing - 6 threads sharing resources - wait() and notify()


Similar Threads

  1. Threads wait() &notify() deadlock
    By mariki in forum Threads and Synchronization
    Replies: 6
    Last Post: 07-20-2012, 09:37 PM
  2. Threads synchronization with wait() & notify() problem
    By Cropcircles in forum Threads and Synchronization
    Replies: 4
    Last Post: 03-25-2012, 10:44 PM
  3. wait() and notify()
    By jomypgeorge in forum New To Java
    Replies: 4
    Last Post: 02-15-2011, 08:58 AM
  4. Need help with wait and notify
    By mityay in forum Threads and Synchronization
    Replies: 3
    Last Post: 01-06-2011, 04:24 PM
  5. Need help with wait() and notify()
    By Mkaveli in forum Threads and Synchronization
    Replies: 2
    Last Post: 03-30-2010, 11:58 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
  •