• Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread Question

 
Michael Hubele
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some theory questions about threads.

Be a� // is this when you extend Thread?
have a� // when you implment Runnable?
own a� // no clue.

This is about all I have to go on.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's an easy beginner's heuristic to say if something "is a" something else you could extend the base class. In practice this can be misleading. "Is a" in the real world and "extends" in Java OO design tend to diverge and mean different things. It's not a bad thing to look at, but don't treat it as a foolproof binary switch.

It's been asked many times here when to extend Thread and when to implement Runnable, and we haven't come up with much of any reason to ever extend Thread. Further, it's dangerous to extend any concrete class and it's a good thing to use the most abstract option you have at any time, so we go firmly with "implement Runnable."

Hope that helps!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!