jdk/src/java.base/share/classes/java/util/concurrent/FutureTask.java
changeset 36936 bfcdf736a998
parent 33674 566777f73c32
child 39725 9548f8d846e9
equal deleted inserted replaced
36935:9a10a2c4dc13 36936:bfcdf736a998
   172                 try {
   172                 try {
   173                     Thread t = runner;
   173                     Thread t = runner;
   174                     if (t != null)
   174                     if (t != null)
   175                         t.interrupt();
   175                         t.interrupt();
   176                 } finally { // final state
   176                 } finally { // final state
   177                     U.putOrderedInt(this, STATE, INTERRUPTED);
   177                     U.putIntRelease(this, STATE, INTERRUPTED);
   178                 }
   178                 }
   179             }
   179             }
   180         } finally {
   180         } finally {
   181             finishCompletion();
   181             finishCompletion();
   182         }
   182         }
   228      * @param v the value
   228      * @param v the value
   229      */
   229      */
   230     protected void set(V v) {
   230     protected void set(V v) {
   231         if (U.compareAndSwapInt(this, STATE, NEW, COMPLETING)) {
   231         if (U.compareAndSwapInt(this, STATE, NEW, COMPLETING)) {
   232             outcome = v;
   232             outcome = v;
   233             U.putOrderedInt(this, STATE, NORMAL); // final state
   233             U.putIntRelease(this, STATE, NORMAL); // final state
   234             finishCompletion();
   234             finishCompletion();
   235         }
   235         }
   236     }
   236     }
   237 
   237 
   238     /**
   238     /**
   246      * @param t the cause of failure
   246      * @param t the cause of failure
   247      */
   247      */
   248     protected void setException(Throwable t) {
   248     protected void setException(Throwable t) {
   249         if (U.compareAndSwapInt(this, STATE, NEW, COMPLETING)) {
   249         if (U.compareAndSwapInt(this, STATE, NEW, COMPLETING)) {
   250             outcome = t;
   250             outcome = t;
   251             U.putOrderedInt(this, STATE, EXCEPTIONAL); // final state
   251             U.putIntRelease(this, STATE, EXCEPTIONAL); // final state
   252             finishCompletion();
   252             finishCompletion();
   253         }
   253         }
   254     }
   254     }
   255 
   255 
   256     public void run() {
   256     public void run() {