Hello,
It's not quite it. The wait () / notify () must be done on the main thread. So the Threads "executive" must have a reference Thread father, something like this:
Code:
Public class Executive extends Thread {
private Thread thpri;
private boolean iswork;
Public Executive(Thread thpri) {
this.thpri = ThreadPrincipal;
}
Public synchronized void setWorking(boolean iswork) {
this.iswork = IsWorking;
}
Public synchronized boolean iswork() {
return iswork;
}
Public void run() {
setWorking(true);
/ / Do the processing
end();
}
Public synchronized void end() {
setWorking(false);
thpri.notify();
}
}
Bookmarks