This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes How to Manage Thread wait and notify Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "How to Manage Thread wait and notify" Watch "How to Manage Thread wait and notify" New topic
Author

How to Manage Thread wait and notify

Cheenath Ajay
Ranch Hand

Joined: Jan 26, 2006
Posts: 32
I have Two Threads


Thread 1: Started execution � low priority

Thread 2: In between Thread 1�s execution, Thread 2 also started � high priority


As per the design


Condition 1: Thread 2 execution should suspend Thread 1 execution

Condition 2: After the Thread 2 execution, Thread 1 should resume its suspended execution



Can any one help me on this?



Thanks in advance,


-Ajay Cheenath
Edward Harned
Ranch Hand

Joined: Sep 19, 2005
Posts: 291

Sounds like a home work assignment.

Use wait() and notify() like your question suggests. For how, read the concurrency tutorial, Tutorial


Ed's latest article: A Java Parallel Calamity http://coopsoft.com/ar/Calamity2Article.html
Saurabh Patil
Ranch Hand

Joined: Dec 11, 2005
Posts: 47

The functions in thread class themselves define clearly when and where they should be used and wait() and notify() are no exceptions. Also see notifyAll()


Preparing for OCPJWCD 6.
Cheenath Ajay
Ranch Hand

Joined: Jan 26, 2006
Posts: 32
Thanks for your input.
Let me move little ahead with my initial question
What I have is a collection of Thread objects
In certain point of time i need them to execute and some of them to suspend and resume, But here the issue is condition for handling these operations are gathered from different threads,
Means using one thread calling start another for wait and notify
So that java throwing execption complaining this
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: How to Manage Thread wait and notify
 
jQuery in Action, 3rd edition