aspose file tools*
The moose likes Threads and Synchronization and the fly likes Thread Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Thread Problem" Watch "Thread Problem" New topic
Author

Thread Problem

Krishna Pratap Singh
Greenhorn

Joined: Oct 17, 2010
Posts: 4
I have been trying to solve a problem involving thread communication using wait() and notify(). Basically i have 2 threads T1 and T2 and i want them to be executed in the following order

T1 , T2, T1, T2 ..... How can i achieve that?

Actual Problem: There are 2 threads T1 - which prints odd numbers (say 1 - 100) and T2 - which prints even numbers (1 - 100). Now, the output should be 1, 2, 3, 4 , 5 , .... 100
Harsha Smith
Ranch Hand

Joined: Jul 18, 2011
Posts: 287
Here is the code
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3097
    
  33

Harsha Smith wrote:Here is the code <code>

Please dont provide the complete code/solution.

You can help by providing hints on how to proceed with the solution.


Mohamed Sanaulla | My Blog
Krishna Pratap Singh
Greenhorn

Joined: Oct 17, 2010
Posts: 4
Thank you very much Harsha , It is working properly.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

harsha must have a lot of time on his hands lol


SCJP
Visit my download page
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread Problem