Code example for FutureTask

Methods: getrun

     * @param c The Callable to run 
     * @return The result of the callable 
     * @throws ExecutionException c's exception 
    public static <T> T runOnUiThreadBlocking(Callable<T> c) throws ExecutionException {
        FutureTask<T> task = new FutureTask<T>(c);
        try { 
            return task.get();
        } catch (InterruptedException e) {
            throw new RuntimeException("Interrupted waiting for callable", e);
     * Run the supplied FutureTask on the main thread. The method will block 
     * only if the current thread is the main thread. 
     * @param task The FutureTask to run 
     * @return The queried task (to aid inline construction) 
    public static <T> FutureTask<T> runOnUiThread(FutureTask<T> task) {
        if (runningOnUiThread()) { 
        } else { 
        return task;
Connect your IDE to all the code out there  Get Codota for Java