I have read tutorial concerning background thread(or worker thread) and now I get confused between SwingWorker and daemon thread, are they the same? If i’m writing non GUI application should i create SwingWorker or daemon thread since they both do the job in background?
I have read tutorial concerning background thread(or worker thread) and now I get confused
Share
There are two types of
Threads: daemons and non-daemons. The JVM will cease execution when there all non-daemonThreads stop running.SwingWorkers are a utility for performing some time expensive task asynchronously from the Event Dispatch Thread to prevent your GUI from becoming unresponsive. ASwingWorkeris not aThread, it is aRunnabletask that can be sumbitted to aThreadfor execution.If you are not doing anything with a GUI, use a
Thread. If you need to perform an action on a separateThreadfor your GUI, use aSwingWorker.