jdk 在什么地方处理Callable的call方法的Exception呢?
来源:互联网 发布:车床马扎克640数控编程 编辑:程序博客网 时间:2024/04/28 07:01
1 FutureTask$Sync里执行callable.call()方法
void innerRun() {
if (!compareAndSetState(0, RUNNING))
return;
try {
runner = Thread.currentThread();
if (getState() == RUNNING) // recheck after setting thread
innerSet(callable.call());
else
releaseShared(0); // cancel
} catch (Throwable ex) {
innerSetException(ex);
}
}
2 然后赋值给 exception = t;
void innerSetException(Throwable t) {
for (;;) {
int s = getState();
if (s == RAN)
return;
if (s == CANCELLED) {
// aggressively release to set runner to null,
// in case we are racing with a cancel request
// that will try to interrupt runner
releaseShared(0);
return;
}
if (compareAndSetState(s, RAN)) {
exception = t;
result = null;
releaseShared(0);
done();
return;
}
}
}
3 然后在get的时候:
V innerGet() throws InterruptedException, ExecutionException {
acquireSharedInterruptibly(0);
if (getState() == CANCELLED)
throw new CancellationException();
if (exception != null)
throw new ExecutionException(exception);
return result;
}
V innerGet(long nanosTimeout) throws InterruptedException, ExecutionException, TimeoutException {
if (!tryAcquireSharedNanos(0, nanosTimeout))
throw new TimeoutException();
if (getState() == CANCELLED)
throw new CancellationException();
if (exception != null)
throw new ExecutionException(exception);
return result;
}
- jdk 在什么地方处理Callable的call方法的Exception呢?
- 我们的未来又在什么地方的潇洒呢
- 如何导入office的类型库?这些类型库都在什么地方呢?
- 如何导入office的类型库?这些类型库都在什么地方呢?
- JavaScript的应用在什么地方?
- JavaScript的应用在什么地方?
- JavaScript的应用在什么地方?
- 最代码的上传的代码文件存储什么地方呢?
- 文件应该存储在手机的什么地方?
- 你的变量究竟存储在什么地方?
- 你的变量究竟存储在什么地方?
- JavaScript应放在页面的什么地方
- 你的变量究竟存储在什么地方?
- 你的变量究竟存储在什么地方?
- 中国的“浪潮之颠”在什么地方?
- JavaScript应放在页面的什么地方
- 你的变量究竟存储在什么地方?
- 你的变量究竟存储在什么地方?
- ExtJs CheckboxSelectionModel 全选操作后 清空表格头的checkBox
- 这个得看看
- DOS中断例程应用
- ${parameter:?word} 用法
- eclipe连接cvs报错“套接字异常:connection reset”、"connection reset by peer"、“caused connection abort: recv fa”等
- jdk 在什么地方处理Callable的call方法的Exception呢?
- java对数据库的封装
- 矩阵乘法在程序中的使用----如有错误欢迎指出
- ireport table 合并
- 梦想---从这里开始
- 使用UltraEdit32编辑器格式化源码功能 XML、Java、C/C++、C#
- HTML5编写的小游戏
- jQuery对下拉框的操作
- CentOS增加删除获取root权限用户