Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-19-2008, 02:38 PM
Member
 
Join Date: May 2008
Posts: 3
integralli is an unknown quantity at this point
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.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-19-2008, 03:09 PM
sanjeevtarar's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Delhi(India)
Posts: 249
sanjeevtarar is on a distinguished road
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,संजीव
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-19-2008, 04:04 PM
Member
 
Join Date: May 2008
Posts: 3
integralli is an unknown quantity at this point
a console program would help me a lot. thank you in advance.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-19-2008, 06:50 PM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 508
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
Ohhh , you mean, you want a ready to run java console program?

What have you done so far?
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-20-2008, 03:17 PM
Member
 
Join Date: May 2008
Posts: 3
integralli is an unknown quantity at this point
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.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 06-20-2008, 10:27 PM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 145
Nicholas Jordan is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 06-21-2008, 05:34 PM
Member
 
Join Date: Jun 2008
Posts: 89
Fubarable is on a distinguished road
Quote:
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!
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Some input on a homework alcohole4life New To Java 1 05-23-2008 05:18 PM
data from the main/GUI thread to another runnin thread... cornercuttin Threads and Synchronization 2 04-23-2008 11:30 PM
Problem using thread +rmi in my homework IbrahimAbbas Threads and Synchronization 10 04-14-2008 10:24 PM
If JNI thread call the java object in another thread, it will crash. skaterxu Advanced Java 0 01-28-2008 08:02 AM
Creating a Thread (extending Java Thread Class) JavaForums Java Blogs 0 12-19-2007 10:31 AM


All times are GMT +3. The time now is 11:44 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org