Callable 和Future 接口使用

来源:互联网 发布:室内设计案例优化 编辑:程序博客网 时间:2024/04/29 17:39

使用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());



0 0
原创粉丝点击