2.Future<V>

Future接口,顧名思義標的一個任務的未來:要么執行完成要么被取消
方法說明:
1.boolean cancel(boolean mayInterruptIfRunning);
Attempts to cancel execution of this task. This attempt will
fail if the task has already completed, has already been cancelled,
or could not be cancelled for some other reason
取消執行任務。如果任務已經執行完成,或者已經取消,或者由于其他原因不能被取消,則取消失敗
通過參數設置是否打斷任務的執行
2.boolean isCancelled();
if this task was cancelled before it completed normally
查看正常結束之前是否被取消
3.boolean isDone();
if this task completed
查看任務是否已結束
4.V get() throws InterruptedException, ExecutionException;
Waits if necessary for the computation to complete, and then
retrieves its result
等到任務執行結束(如需要等待),然后返回結果
5.V get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException;
Waits if necessary for at most the given time for the computation
to complete, and then retrieves its result, if available.
在指定的等待時間內讓任務執行(如需要等待),如果有結果就返回

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • 5.SDWebImageDownloader 下面分析這個類看這個類的結構 這個類的屬性比較多。 先看這個類的pu...
    充滿活力的早晨閱讀 1,107評論 0 0
  • Android Handler機制系列文章整體內容如下: Android Handler機制1之ThreadAnd...
    隔壁老李頭閱讀 4,312評論 2 12
  • 1、一般來說,我們常見的使用圖片的優化方案有base64編碼、雪碧圖、字體圖片、圖片壓縮等 base64編碼(1 ...
    Axiba閱讀 2,739評論 0 0
  • 聽說你們那里很冷 可我這里卻冬陽暖照 此刻我拿一條板凳兒 坐于后園大樹下 直視太陽的光輝 陽光輕撫著我的面龐 可我...
    暮罹閱讀 155評論 0 0
  • 看百度百科 中文名 主營業務 對象 經營目標而從事的日常活動 接下來要做的是把課文上的邏輯整理出來,做出思維導...
    aabebw閱讀 198評論 0 0