문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top