I now have 2 Android threads, one is the view thread, one is the worker thread, and I now want the project thread to pause until the view thread's OnDraw method is called before continuing to run
How to do? How to wait for a signal
Processing methods
To pass an object in a java2 thread, let one thread notify the other thread as follows, calling in the worker thread
Stick.wait ();
When the view thread finishes its onDraw work, it calls this:
You can call Stick.notify () when the view thread finishes calling OnDraw.
Stick.notify ();
Note that the view thread has the requirements for the display on that object. For you, this should be fairly simple to execute with a small sync block:
123456 |
void
ondraw () {
  
...
  
synchronized
(stick) {
    
stick.notify ();
  
}
}
// end onDraw()
|
Original address: http://www.itmmd.com/201411/97.html
This article by Meng Meng's IT person to organize the release, reprint must indicate the source.
Sync issues between Android threads