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

Comparing jsr166/src/main/java/util/concurrent/Executors.java (file contents):
Revision 1.26 by tim, Fri Dec 5 17:56:24 2003 UTC vs.
Revision 1.27 by tim, Sat Dec 6 04:31:03 2003 UTC

# Line 44 | Line 44 | public class Executors {
44       * A wrapper class that exposes only the ExecutorService and
45       * ScheduleExecutor methods of a ScheduledThreadPoolExecutor.
46       */
47 <    private static class DelegatedScheduledExecutorService
48 <            extends DelegatedExecutorService
49 <            implements ScheduledExecutor {
50 <        
47 >    private static class DelegatedScheduledExecutorService
48 >            extends DelegatedExecutorService implements ScheduledExecutor {
49          private final ScheduledExecutor e;
50          DelegatedScheduledExecutorService(ScheduledThreadPoolExecutor executor) {
51              super(executor);
# Line 175 | Line 173 | public class Executors {
173                                      new SynchronousQueue<Runnable>(),
174                                      threadFactory));
175      }
176 <    
179 <    
176 >  
177      /**
178       * Creates a thread pool that can schedule commands to run after a
179       * given delay, or to execute periodically.
# Line 184 | Line 181 | public class Executors {
181       * an <tt>ExecutorService</tt>.
182       */
183      public static ScheduledExecutor newScheduledThreadPool() {
184 <        return newScheduledThreadPool(0);
184 >        return newScheduledThreadPool(1);
185      }
186      
190    
187      /**
188       * Creates a thread pool that can schedule commands to run after a
189       * given delay, or to execute periodically.
# Line 197 | Line 193 | public class Executors {
193       * an <tt>ExecutorService</tt>.
194       */
195      public static ScheduledExecutor newScheduledThreadPool(int corePoolSize) {
196 <        return newScheduledThreadPool(corePoolSize, null);
196 >        return new DelegatedScheduledExecutorService
197 >            (new ScheduledThreadPoolExecutor(corePoolSize));
198      }
199  
203
200      /**
201       * Creates a thread pool that can schedule commands to run after a
202       * given delay, or to execute periodically.
# Line 213 | Line 209 | public class Executors {
209       */
210      public static ScheduledExecutor newScheduledThreadPool(int corePoolSize,
211                                                             ThreadFactory threadFactory) {
212 <        return newScheduledThreadPool(corePoolSize, threadFactory, false, false);
213 <    }
218 <
219 <    
220 <    /**
221 <     * Creates a thread pool that can schedule commands to run after a
222 <     * given delay, or to execute periodically.
223 <     * @param corePoolSize the number of threads to keep in the pool,
224 <     * even if they are idle.
225 <     * @param threadFactory the factory to use when the executor
226 <     * creates a new thread.
227 <     * @param continueExistingPeriodicTasksAfterShutdown  whether to
228 <     * continue executing existing periodic tasks even when the returned
229 <     * executor has been <tt>shutdown</tt>.
230 <     * @param executeExistingDelayedTasksAfterShutdown  whether to
231 <     * continue executing existing delayed tasks even when the returned
232 <     * executor has been <tt>shutdown</tt>.
233 <     * @return a <tt>ScheduledExecutor</tt> that may safely be cast to
234 <     * an <tt>ExecutorService</tt>.
235 <     */
236 <    public static ScheduledExecutor newScheduledThreadPool(
237 <            int corePoolSize,
238 <            ThreadFactory threadFactory,
239 <            boolean continueExistingPeriodicTasksAfterShutdown,
240 <            boolean executeExistingDelayedTasksAfterShutdown) {
241 <                
242 <        ScheduledThreadPoolExecutor stpe = threadFactory == null ?
243 <            new ScheduledThreadPoolExecutor(corePoolSize) :
244 <            new ScheduledThreadPoolExecutor(corePoolSize, threadFactory);
245 <            
246 <        stpe.setContinueExistingPeriodicTasksAfterShutdownPolicy(
247 <            continueExistingPeriodicTasksAfterShutdown);
248 <            
249 <        stpe.setExecuteExistingDelayedTasksAfterShutdownPolicy(
250 <            executeExistingDelayedTasksAfterShutdown);
251 <        
252 <        return new DelegatedScheduledExecutorService(stpe);
212 >        return new DelegatedScheduledExecutorService
213 >            (new ScheduledThreadPoolExecutor(corePoolSize, threadFactory));
214      }
254    
215  
216      /**
217       * Executes a Runnable task and returns a Future representing that

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines