Android examples for java.util.concurrent:FutureTask
Create FutureTask from Runnable
//package com.java2s; import android.support.annotation.NonNull; import java.util.concurrent.FutureTask; public class Main { public static FutureTask backgroundThread( @NonNull final Runnable runnable) { final FutureTask<Void> futureTask = new FutureTask<>( new Runnable() { @Override/*from w ww .j a v a2 s .c o m*/ public void run() { new Thread(runnable).start(); } }, null); futureTask.run(); return futureTask; } }