How do I get one thread to tell another to wait?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Andrew_Casale
Posted On:   Thursday, October 7, 2010 04:31 PM

Hi, I am new to threads, and what I want to do is to get a thread to tell another thread to wait. This is what I am trying to do... Runnable someRunnable = new Runnable(){...} //some runnable, i have no control over what it is . . . . Runnable timer = new Runnable(){ public void run(){ task = new Thread(someRunnable); task.start(); while(true){//this loop just checks the condition while(condition == true){ //tell task to wait //another part of the //code will notify task and //set condition to false } } } }; I am not sure if I am exactly clear or if my code is any g   More>>

Hi, I am new to threads, and what I want to do is to get a thread to tell another thread to wait. This is what I am trying to do...

			

Runnable someRunnable = new Runnable(){...}
//some runnable, i have no control over what it is
.
.
.
.
Runnable timer = new Runnable(){
public void run(){
task = new Thread(someRunnable);
task.start();
while(true){//this loop just checks the condition
while(condition == true){
//tell task to wait
//another part of the
//code will notify task and
//set condition to false
}
}

}
};


I am not sure if I am exactly clear or if my code is any good. Any help will be appreciated, and let me know if you have any questions about what I am trying to do. Thanks.    <<Less
About | Sitemap | Contact