ExecutorService中submit和execute的区别
来源:互联网 发布:四川禄宏微交易 知乎 编辑:程序博客网 时间:2024/05/17 20:29
接收的参数不一样
submit有返回值,而execute没有
Method submit extends base method Executor.execute by creating and returning a Future that can be used to cancel execution and/or wait for completion.
3、submit方便Exception处理
There is a difference when looking at exception handling. If your tasks throws an exception and if it was submitted with execute this exception will go to the uncaught exception handler (when you don't have provided one explicitly, the default one will just print the stack trace to System.err). If you submitted the task with submit any thrown exception, checked or not, is then part of the task's return status. For a task that was submitted with submit and that terminates with an exception, the Future.get will rethrow this exception, wrapped in an ExecutionException.
submit()能在返回的Future对象调用get()方法的时候再次抛出线程中的异常,而execute()会交由线程的UncaughtExceptionHandler去处理。
- ExecutorService中submit和execute的区别
- ExecutorService中submit和execute的区别
- ExecutorService中submit和execute的区别
- ExecutorService中submit和execute的区别
- ExecutorService中submit和execute的区别
- ExecutorService中submit和execute的区别
- ExecutorService中submit和execute的区别
- ExecutorService中submit和execute的区别
- ExecutorService中submit和execute的区别
- ExecutorService中submit和execute的区别
- ExecutorService中submit和execute的区别
- ExecutorService中submit和execute的区别
- ExecutorService中submit和execute的区别
- ExecutorService中submit和execute的区别
- ExecutorService中submit和execute的区别
- ExecutorService中submit和execute的区别
- ExecutorService中submit()和execute()的区别
- ExecutorService中submit和execute的区别
- 炸弹人游戏_暴力枚举
- Ntrip协议相关(客户端软件或代码)
- GridLayoutManager高度无法设置为WRAP_CONTENT(Vertical情况下)
- 一个支持8~16人的小型网络游戏的编写
- Android中 Bitmap和Drawable相互转换的方法
- ExecutorService中submit和execute的区别
- C++实验1
- 新萝卜家园GHOST WIN7系统32,64位官方版下载
- mongodb丢失数据的原因剖析
- leetcode:N-Queens II
- Android设计模式系列-单例模式
- win7开机显示密码错误咋办?
- linux 下恢复rm -rf删除的文件
- 设计模式:简单工厂、工厂方法、抽象工厂之小结与区别