java.lang.Runnable
public interface Runnable {
public abstract void run();
}
java.util.concurrent.Callable
public interface Callable<V> {
V call() throws Exception;
}
java.util.concurrent.Future
public interface Future<V> {
boolean cancel(boolean mayInterruptIfRunning); //尝试取消当前任务
boolean isCancelled(); //判断当前任务是否取消
boolean isDone(); //当前任务是否完成
V get() throws InterruptedException, ExecutionException; //阻塞直到获得结果
V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException;
}
java.util.concurrent.RunnableFuture
public interface RunnableFuture<V> extends Runnable, Future<V> {
void run();
}
线程常用接口
最新推荐文章于 2023-01-09 17:32:38 发布