Skip to main content

How to break a threadpool

1 reply [Last post]
Joined: 2008-12-23


We have a service that (uses java.util.concurrent) maintains a ThreadPool and executes many short running tasks. I have to create a corrupt task that will cause thread leakage and cause the ThreadPool to become empty. This will simulate a production issue that another dev suspects. How do I achieve that. I tried throwing RuntimeException and Error but that did not work. Please help.

Jack P

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2005-11-01

You cannot do that with the standard ThreadPools, if you could it would be a bug in the pool. However you can create a custom ThreadPoolExecutor which will break as you suggest.