runOnUiThread()不会调用我的Runnable的run()

时间:2014-05-18 12:45:36

标签: java android multithreading user-interface

我尝试使用runOnUiThread()方法,但由于某种原因,我的run()中的代码永远不会被调用。

结果我的程序陷入僵局(CountDownLatch永远等待着。)

有人可以说明为什么我的run()方法没有在UI线程上调用吗?

private final CountDownLatch m_latch = new CountDownLatch(1);

m_mainActivity.runOnUiThread(new Runnable(){
    public void run() {
        // Here I have a breakpoint (never stops here)

        // Do somethings that has to be done on the main thread

        m_latch.countDown(); 
    }           
});

try {
    // Wait for m_bundle to get set         
    m_latch.await();
} catch (InterruptedException e) {}

0 个答案:

没有答案