List of usage examples for android.os ConditionVariable block
public boolean block(long timeout)
From source file:com.facebook.FacebookActivityTestCase.java
protected void runOnBlockerThread(final Runnable runnable, boolean waitForCompletion) { Runnable runnableToPost = runnable; final ConditionVariable condition = waitForCompletion ? new ConditionVariable(!waitForCompletion) : null; if (waitForCompletion) { runnableToPost = new Runnable() { @Override/*from w w w. j av a2 s .c o m*/ public void run() { runnable.run(); condition.open(); } }; } TestBlocker blocker = getTestBlocker(); Handler handler = blocker.getHandler(); handler.post(runnableToPost); if (waitForCompletion) { boolean success = condition.block(10000); assertTrue(success); } }