We are using a CachedThreadPool created via the ExecutorService#newCachedThreadPool. (Java 1.6). We are getting errors elsewhere in our code: "unable to create new native thread" which we've diagnosed as an out of memory problem. When this problem is happening, the block of code where we call submit (we use submit, not execute) slows down. We suspect that the ThreadPool is having the same issue "unable to create new native thread" when it is trying to create new threads to process the tasks, but we can't be sure.
Is there any way to catch exceptions from inside the ExecutorService? To be 100% clear, I'm not talking about the tasks given to the ExecutorService, but from the ExecutorService itself.