线程常用接口

来源:互联网 发布:java agent premain 编辑:程序博客网 时间:2024/05/21 12:32
java.lang.Runnablepublic interface Runnable {        public abstract void run();}java.util.concurrent.Callablepublic interface Callable<V> {    V call() throws Exception;}java.util.concurrent.Futurepublic 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.RunnableFuturepublic interface RunnableFuture<V> extends Runnable, Future<V> {    void run();}



0 0
原创粉丝点击