I have a worker thread that creates a runnable object and calls runOnUiThread on it, because it deals with Views and controls. I\'d like to use the result of the work of the
I think the simplest way to achieve this is using a "CountDownLatch".
final CountDownLatch latch = new CountDownLatch(1);
runOnUiThread(new Runnable() {
@Override
public void run() {
// Do something on the UI thread
latch.countDown();
}
});
try {
latch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
// Now do something on the original thread
(I believe this question is a duplicate of "How to make timer task to wait till runOnUiThread completed")