Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Different of 'extends Thread' and 'implements Runnable'?  RSS feed

 
Aji Prasetyo
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,

I have a doubt on the different of 'extends Thread' and 'implements Runnable'.
When should I use extends thread and when should I use implements Runnable?

Thank you.
 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of the benefits of an extending from Thread is that you can
customized the lifecycle.

e.g. you can override the interrupt() method to close open resources before
propagating the actual request for interruption.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a writeup on this topic in the FAQ: ExtendingThreadVsImplementingRunnable
 
Aji Prasetyo
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Thank you for the insight and I will study the FAQ.

 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!