Callable 和Future 接口使用

使用Callable和Future的組合,異步獲取數據,Callable負責執行,Future獲取執行結果

1:Callable和Future 

ExecutorService executor = Executors.newCachedThreadPool();
Future future=executor.submit(new Callable(){

    @Override
    public Object call() throws Exception {
        return null;
    }
});
System.out.print(future.get());



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章