Results 1 to 7 of 7

Thread: thread homework

  1. #1
    integralli is offline Member
    Join Date
    May 2008
    Posts
    3
    Rep Power
    0

    Default thread homework

    Can anyone help me to implement the code for the following assignment:

    There is a "box" where numbers are written. A thread named WriteThread writes a number to the box, while another thread ReadThread reads the number from the box.

    Access to this box needs to be synchronized and any number written by WriteThread has to be read by ReadThread.

    WriteThread cannot write the next number if the number is not read by ReadThread first and vice versa.

    I appreciate any help.

  2. #2
    sanjeevtarar's Avatar
    sanjeevtarar is offline Senior Member
    Join Date
    Apr 2008
    Location
    Jaipur(India)
    Posts
    318
    Rep Power
    7

    Default

    do you need a simple console program means on console you can see the written number or any UI also that will show the numbers..??
    sanjeev,संजीव

  3. #3
    integralli is offline Member
    Join Date
    May 2008
    Posts
    3
    Rep Power
    0

    Default

    a console program would help me a lot. thank you in advance.

  4. #4
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    Ohhh :( , you mean, you want a ready to run java console program?

    What have you done so far?
    freedom exists in the world of ideas

  5. #5
    integralli is offline Member
    Join Date
    May 2008
    Posts
    3
    Rep Power
    0

    Default

    if someone already has the code for this example, or something similar to the above mentioned example then I believe it would be easyer for the one to post the code, otherwise a guidance on how to do implement it would be very much appreciated.

  6. #6
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Default

    Remarkably simple to say, much more difficult to make run reliably in a business setting. Because it is a student project we can just tell you to use a synchronized method.

    We are not going to write the code for you, that will not stick.

    public static synchronized Access(Box theBox) {} or something like that.

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

    Default

    if someone already has the code for this example, or something similar to the above mentioned example then I believe it would be easyer for the one to post the code...
    Easier, yes, but hey, this is your assignment. Please first show some effort!

Similar Threads

  1. Some input on a homework
    By alcohole4life in forum New To Java
    Replies: 1
    Last Post: 05-23-2008, 04:18 PM
  2. data from the main/GUI thread to another runnin thread...
    By cornercuttin in forum Threads and Synchronization
    Replies: 2
    Last Post: 04-23-2008, 10:30 PM
  3. Problem using thread +rmi in my homework
    By IbrahimAbbas in forum Threads and Synchronization
    Replies: 10
    Last Post: 04-14-2008, 09:24 PM
  4. Replies: 0
    Last Post: 01-28-2008, 07:02 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
  •