Skip to main content

How to break a threadpool

1 reply [Last post]
cooldude123
Offline
Joined: 2008-12-23
Points: 0

Hi

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.

Thanks
Jack P

Reply viewing options

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

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.