首页 > 编程语言 > 详细

Java Future 线程接口

时间:2021-09-07 16:32:22      阅读:29      评论:0      收藏:0      [点我收藏+]

源码展示

package java.util.concurrent;

/**
 * A Future represents the result of an asynchronous computation.
 */
public interface Future<V> {

    /**
     * Attempts to cancel execution of this task.  
     */
    boolean cancel(boolean mayInterruptIfRunning);

    /**
     * Returns true if this task was cancelled before it completed normally.
     */
    boolean isCancelled();

    /**
     * Returns true if this task completed.
     */
    boolean isDone();

    /**
     * Waits if necessary for the computation to complete, and then
     * retrieves its result.
     */
    V get() throws InterruptedException, ExecutionException;

    /**
     * Waits if necessary for at most the given time for the computation
     * to complete, and then retrieves its result, if available.
     *
     * @param timeout the maximum time to wait
     * @param unit the time unit of the timeout argument
     */
    V get(long timeout, TimeUnit unit)
        throws InterruptedException, ExecutionException, TimeoutException;
}

Java Future 线程接口

原文:https://www.cnblogs.com/feiqiangsheng/p/15237458.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!