Reputation: 497
I have just started to use SwingWorker
for an iterative algorithm. After creating object of a class extended from SwingWorker, I performed the execute() function in the contructor function of my main class extended from JFrame. I use doInBackground() and process() functions during application runs. I don't need to stop the execution throughout the application. When user closes my JFrame application, do I need to carry out any stopping or cleaning task for SwingWorker? I mean, is it safe to close directly the JFrame application which uses SwingWorker?
Thanks
Upvotes: 1
Views: 56
Reputation: 347332
SwingWorker
uses it's own ExecutorService
, which backed by it's own ThreadFactory
which generates daemon Thread
s, meaning that the JVM will be able to exit once all the non-daemon thread's have finished.
Is it safe? That would come down to what it is your SwingWorker
is actually doing, but if you're not holding any resources open or have other processes reliant on the result of the SwingWorker
in order to completely their jobs (and close resources, etc), it should be
Upvotes: 3