multithreading - Android: Possible for background thread to block until UI thread finishes operation? -
Is it possible to block the handler of key UI threads for a background thread and until the message is not served Have you done
The reference to this is that I would love to use my remote service to work with my main main UI thread, instead of the thread thread, which I received the IPC request.
This is what you should do to make this method known to to create synchronous in nature () and wait () will run on the UI thread and inside the run () and control the doSomething () Once it will end, it will definitely put the calling thread in sleep.
Public Nullify something (MyObject talk) {string sink = ""; Classroom DoInBackground implements Runnable {MyObject; String sync; Public DoInBackground (MyObject talk, string sync) {this.thing = thing; This.sync = sync; } @ Override Public Wide Run () {synchronize (sync) {methodToDo something (thing); // sync.notify (background) in the background; // Alert the previous thread to be alerted}}} Downline down the background = new dinback background (talk, sync); Syncing (sync) {try {activity activity = meet anywhere (); Activity.runOnUiThread (bottom); Sync.wait (); // Close the block until the task is completed} Grip (Interrupted ejection e) {Log.e ("PlaylistControl", "Error in Vote", e); }}}
Comments
Post a Comment