• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread Problem

 
Krishna Pratap Singh
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 287
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the code
 
Mohamed Sanaulla
Saloon Keeper
Pie
Posts: 3159
33
Google App Engine Java Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Krishna Pratap Singh
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Harsha , It is working properly.
 
Randall Twede
Ranch Hand
Posts: 4353
2
Java
  • 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
harsha must have a lot of time on his hands lol
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic