在java.util.concurrent.FutureTask中,run()已实现如下:
public void run() {
...
V result;
boolean ran;
try {
result = c.call();
ran = true;
} catch (Throwable ex) {
result = null;
ran = false;
setException(ex);
}
if (ran)
set(result);
...
}
为什么不实施如下:
public void run() {
...
V result;
try {
result = c.call();
set(result);
} catch (Throwable ex) {
result = null;
setException(ex);
}
...
}
对此有何特别的考虑?