I know that I can use the following to have thread B waiting for thread A to finish before proceeding:
class A extends Thread{
public void run(){
....
}
}
class B extends Thread{
private Thread someThread;
B(Thread t){
someThread=t;
}
public void run(){
someThread.join();
...//then proceed
}
}
But how can I do this in the run() of A to call B and then wait it finish before proceeding? That is, I want something like
class A extends Thread{
private Thread someThread;
B(Thread t){
someThread=t;
}
public void run(){
//*how to start B and wait it finish?
...//then proceed
}
}
class B extends Thread{
public void run(){
....
}
}
If possible, a simpler solution would be to start
Bfirst, thenb.join();, and do the same forAin the client code:There is no sense in starting a thread for it to just fire up and join on another tread before proceeding.