• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread vs Runnable

 
vijay kumar
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any other differences between Implementing Runnable interface and Thread class apart from OO opttion.
 
Saket Barve
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Functionality wise, no.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you extend Thread, each instance will automatically have a reference in a ThreadGroup - this has some implications for locating instances of your class and other stuff. See the java.lang.ThreadGroup JavaDocs.
Bill
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's been noted many times that it was probably a mistake for Thread to
implement Runnable: it confuses the task with the worker. Since one
almost never overrides Thread methods other than run, keep it simple
and implement Runnable and then use Thread without subclassing:
How bad is it that Thread implements Runnable? At another Java site,
I saw some nasty code where someone tried to "restart" a thread like
this:
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to "Threads and Synchronization."
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might be interested in this thread.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic