Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Java-ites:
I'm working my way through Teach Yourself Java in 21 Days and I've just completed the chapter on SwingWorker, but I'm confused about the difference (if there is one) between it an using the Thread class. Can someone clarify? Thanks.

Dre
Posted
Comments
Sergey Alexandrovich Kryukov 24-Sep-13 9:42am    
I'm not going to say that this exercise is not useful, but please read this encouraging well-known article:
Peter Norvig, Teach Yourself Programming in Ten Years,
http://norvig.com/21-days.html[^].

—SA
pasztorpisti 28-Sep-13 18:09pm    
:-) :-) :-) This was new for me. The title is so ridiculous, probably because the "Teach yourself X in 24 hours" series is so well known and because X here is not a technology or language but simply "Programming"!
Sergey Alexandrovich Kryukov 29-Sep-13 1:25am    
Pretty reasonable article, isn't it? :-)
—SA
pasztorpisti 29-Sep-13 5:10am    
Sure! :-) (Teach yourself Multithreading in 24 Hours..., no in 10 Minutes!)

It just helps you to use an event dispatching thread. Everything is explained here:
http://en.wikipedia.org/wiki/SwingWorker[^].

Just a note: your question is one of the illustration of the simple fact: the questions about "difference" are usually logically invalid. If you don't see why, please tell us the difference between apple and Apple.

—SA
 
Share this answer
 
Comments
pasztorpisti 28-Sep-13 18:14pm    
+5. SwingWorker is just a utility class that hides actual threading model and result message passing form the worker thread to the swing gui thread (as you probably know) and this confuses so many people (just like any other threading patterns) - they think that some kind of magic is goin on behind the curtains...
Sergey Alexandrovich Kryukov 29-Sep-13 1:28am    
Thank you.
While hiding the threading model can be practically useful for development, I think it's very important to understand threading deeper then the level of .NET, Java, or OS API. Black box approach may be not the most effective here.
—SA
Thank you Sergey. I took a quick look at the article about taking time to learn development, and from the bit I read I have to say I agree with the article, but unfortunately when you're unemployed, and your unemployment benefits are about to run out, you have to do what you can to become marketable.

I will take a look at the wikipedia article. I only ask because I wasn't sure if it was just redundancy or if one method was preferred over another (hiring managers tend to ask those sorts of things on interviews, and I like to be prepared).

Thanks for the feedback.

Andre
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900