我对FutureTask的run()的实现有一些疑问

时间:2017-09-22 03:33:43

标签: java

在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);
            }     
    ...
} 

对此有何特别的考虑?

0 个答案:

没有答案