What are the advantages of using SwingWorker instead of Thread or Runnable?
What are the advantages of using SwingWorker instead of Thread or Runnable ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Thread and Runnable were part of Java 1.0; they’re as good as they were back then.
The new concurrency classes distill all that’s been learned about multi-threading since then (thank you, Doug Lea and others). Writing multi-threaded code is terribly difficult. The new concurrency classes, including SwingWorker, try to make that easier.
Start by noting the generics for strong typing. There’s a mechanism built in to publish and process both final and intermediate results.
It’d be possible to mimic these with Thread and Runnable, but SwingWorker has done it for you.