Question

I have a Swing application, which uses a ThreadPoolExecutor to perform multiple tasks. At one point, I want to reinitialize everything. I am using executor.purge(); and executor.getQueue().clear(); Is this enough? Are there any better ways / practices to perform this? Thanks in advance.

Était-ce utile?

La solution

IMHO you should just shutdownNow() the pool and create a new one. If not done too often, it's much simpler. It will also behave safely with already running jobs. Moreover the semantics of purge() are a bit fuzzy.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top