[concurrency-interest] Why does new ScheduledThreadPoolExecutor(0) not throw an exception?

Martin Buchholz martinrb at google.com
Fri Dec 5 21:37:16 EST 2008


Hmmmm... I don't remember the details of this change.
corepoolsize of 0 makes sense for ThreadPoolExecutor.

The STPE spec does use the word "almost"
to warn about this possibility.

It might provide a way to make a pool quiescent.
Set corepoolsize to zero during certain times of the day?
Probably there are better ways to do that.

Doug?

 * <p>While this class inherits from {@link ThreadPoolExecutor}, a few
 * of the inherited tuning methods are not useful for it. In
 * particular, because it acts as a fixed-sized pool using
 * {@code corePoolSize} threads and an unbounded queue, adjustments
 * to {@code maximumPoolSize} have no useful effect. Additionally, it
 * is almost never a good idea to set {@code corePoolSize} to zero or
 * use {@code allowCoreThreadTimeOut} because this may leave the pool
 * without threads to handle tasks once they become eligible to run.

Martin


On Fri, Dec 5, 2008 at 18:02, Bill Pugh <pugh at cs.umd.edu> wrote:
> The JavaDoc for Java 1.5 says that new ScheduledThreadPoolExecutor(0) throws
> illegal argument exception.
>
> It should, since such a created ScheduledThreadPoolExecutor is useless. It
> will silently ignore all requests to execute anything.
>
> But in Java 1.6, the spec was changed to say that it throws an execution
> only if the argument is < 0.
>
> Bill
>
>
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>


More information about the Concurrency-interest mailing list