Code example for FutureTask

Methods: runOnMainSyncget

     * @param <R> Type of result to return 
    public <R> R runTestOnUiThreadAndGetResult(Callable<R> callable)
            throws Exception { 
        FutureTask<R> task = new FutureTask<R>(callable);
        return task.get();
     * Loads url on the UI thread and blocks until onPageFinished is called. 
    protected void loadUrlSync(final WebView webview,
                               CallbackHelper onPageFinishedHelper,
                               final String url) throws Exception {
        int currentCallCount = onPageFinishedHelper.getCallCount();
        loadUrlAsync(webview, url);
        onPageFinishedHelper.waitForCallback(currentCallCount, 1, WAIT_TIMEOUT_SECONDS,
Contextual code suggestions in your IDE  Get Codota for Java