Number of tasks (threads) submitted is also not huge in this test scenario.
views:
1260answers:
2I dont see anywhere in the invocation of the Executors.newCachedThreadPool()
methods where a RejectedExecutionException
is thrown. There are only three cases where it appears to be thrown in Java 6:
- when calling
execute()
on aThreadPoolExecutor
and the maximum pool size has been reached. - when calling
execute()
on aThreadPoolExecutor
at the same time thatshutdownNow
, and has essentially lost the race with theshutdownNow
call. - when trying to schedule execution of a runnable in a
ScheduledThreadPoolExecutor
after the executor has been shutdown.
You'll need to provide code samples of how you instantiate and call submit
on the pool (IP should be a non-issue here as we don't need details of the internals of your Callable
classes or anything like that).
Based on the information that you've given, you're almost certainly shutting down the executor service somewhere before submitting the callable to it. Check if you make any calls to shutdown
or shutdownNow
, and if so ensure that you're not adding tasks after this point.
Beyond that, you may want to register your own implementation of java.util.concurrent.RejectedExecutionHandler
in order to aid in debugging; its [rejectedExecution][1] message will be called whenever the executor is unable to accept a task, so you could put some rudimentary state-inspection logic there to help you find the cause.
[1]: http://java.sun.com/javase/6/docs/api/java/util/concurrent/RejectedExecutionHandler.html#rejectedExecution%28java.lang.Runnable, java.util.concurrent.ThreadPoolExecutor)