Code example for FutureTask

Methods: runOnMainSyncget

     * @param <R> Type of result to return 
    public <R> R runTestOnUiThreadAndGetResult(Callable<R> callable)
            throws Throwable { 
        FutureTask<R> task = new FutureTask<R>(callable);
        try { 
            return task.get();
        } catch (ExecutionException e) {
            // Unwrap the cause of the exception and re-throw it. 
            throw e.getCause();
    protected void enableJavaScriptOnUiThread(final AwContents awContents) {
        getInstrumentation().runOnMainSync(new Runnable() {
            public void run() { 
Connect your IDE to all the code out there  Get Codota for Java