ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/CancellableTask.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/CancellableTask.java (file contents):
Revision 1.15 by dl, Sun Sep 7 23:28:21 2003 UTC vs.
Revision 1.16 by dl, Fri Sep 12 15:40:10 2003 UTC

# Line 53 | Line 53 | public class CancellableTask implements
53       * Creates a new CancellableTask which invokes the given
54       * <tt>Runnable</tt> when executed.
55       * @param r the runnable action
56 +     * @throws NullPointerException if runnable is null
57       */
58      public CancellableTask(Runnable r) {
59 +        if (r == null)
60 +            throw new NullPointerException();
61          this.runnable = r;
62      }
63  
# Line 153 | Line 156 | public class CancellableTask implements
156      }
157  
158      /**
159 <     * Reset the run state of this task to its initial state.
159 >     * Reset the run state of this task to its initial state unless
160 >     * it has been cancelled. (Note that a cancelled task cannot be
161 >     * reset.)
162 >     * @return true if successful
163       */
164 <    protected void reset() {
165 <        runnerUpdater.set(this, null);
164 >    protected boolean reset() {
165 >        for (;;) {
166 >            Object r = runner;
167 >            if (r == CANCELLED)
168 >                return false;
169 >            if (runnerUpdater.compareAndSet(this, r, null))
170 >                return true;
171 >        }
172      }
173  
174      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines