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

Comparing jsr166/src/main/java/util/concurrent/ThreadPoolExecutor.java (file contents):
Revision 1.4 by dl, Thu May 29 13:21:28 2003 UTC vs.
Revision 1.5 by dl, Tue Jun 3 16:44:36 2003 UTC

# Line 487 | Line 487 | public class ThreadPoolExecutor implemen
487          }
488      }
489  
490    private static class DequeuableFutureTask<V> extends FutureTask<V> {
491        private final ThreadPoolExecutor tpe;
492        public DequeuableFutureTask(Callable<V> callable, ThreadPoolExecutor tpe) {
493            super(callable);
494            this.tpe = tpe;
495        }
496
497        public DequeuableFutureTask(final Runnable runnable, final V result, ThreadPoolExecutor tpe) {
498            super(runnable, result);
499            this.tpe = tpe;
500        }
501        
502        public boolean cancel(boolean mayInterruptIfRunning) {
503            if (!isDone())
504                tpe.dequeue(this);
505            return super.cancel(mayInterruptIfRunning);
506        }
507    }
508
490      /**
491       * Creates a new <tt>ThreadPoolExecutor</tt> with the given initial
492       * parameters.  It may be more convenient to use one of the factory
# Line 688 | Line 669 | public class ThreadPoolExecutor implemen
669          }
670      }
671  
691    public <T> FutureTask<T> executeAsFuture(Callable<T> task) {
692        FutureTask<T> future = new DequeuableFutureTask<T>(task, this);
693        execute(future);
694        return future;
695    }
696
697    public <T> FutureTask<T> executeAsFuture(Runnable task, T returnValue) {
698        FutureTask<T> future = new DequeuableFutureTask<T>(task, returnValue, this);
699        execute(future);
700        return future;
701    }
702
703
704        
672      public void shutdown() {
673          mainLock.lock();
674          try {
# Line 802 | Line 769 | public class ThreadPoolExecutor implemen
769       *
770       * #return true if the task was removed
771       */
772 <    public boolean dequeue(Runnable task) {
772 >    public boolean remove(Runnable task) {
773          return getQueue().remove(task);
774      }
775  
# Line 1016 | Line 983 | public class ThreadPoolExecutor implemen
983      /**
984       * Method invoked prior to executing the given Runnable in given
985       * thread.  This method may be used to re-initialize ThreadLocals,
986 <     * or to perform logging.
986 >     * or to perform logging. Note: To properly nest multiple
987 >     * overridings, subclasses should generally invoke
988 >     * <tt>super.beforeExecute</tt> at the end of this method.
989       *
990       * @param t the thread that will run task r.
991       * @param r the task that will be executed.
# Line 1026 | Line 995 | public class ThreadPoolExecutor implemen
995      /**
996       * Method invoked upon completion of execution of the given
997       * Runnable.  If non-null, the Throwable is the uncaught exception
998 <     * that caused execution to terminate abruptly.
998 >     * that caused execution to terminate abruptly. Note: To properly
999 >     * nest multiple overridings, subclasses should generally invoke
1000 >     * <tt>super.afterExecute</tt> at the beginning of this method.
1001       *
1002       * @param r the runnable that has completed.
1003       * @param t the exception that cause termination, or null if

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines