• Post Reply Bookmark Topic Watch Topic
  • New Topic

avoid override run method  RSS feed

 
Nada Mohammed
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ,
suppose i have the following class :
class MyThread implements Runnable {
MyThread() {
new Thread(this).start() ;
}
public void run() {
.........
}
the question how we can avoid any subclass from class MyThread to override run method ??? i try to make run method final , static but it doesn't work so pleeease i need help

Thanks for your time
-Nada
 
Akmal Hakim
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nada,
run is a method of Runnable interface. So it is overridden in MyThread class. You cannot override a nonstatic method (here run)
to a staic mrethod. But you can declare it final in this MyThread
class. Correct me if i m wrong.

------------------
AHakim
JavaProfessional
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!