保持线程直到处理程序完成 android

hold thread until handler finish android

您好,我想暂停我的线程,直到处理程序完成。 我测试了 synchronized 但它不能正常工作。

synchronized (handle) 
{
      handle.sendMessage(msg); 
}

看来您需要一个 CountDownLatch:http://developer.android.com/reference/java/util/concurrent/CountDownLatch.html