• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

start()-Method in Thread class

 
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

can someone explain me, why the start() method in the Thread class is not final? Isn't the sole reason for this method to start a new thread execution stack?
But if I override this method in a subclass its whole purpose is vanished. So why isn't it final? Here an example:


Thanks for any help
Bob
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suppose you can write a better or more concrete implementation of start(). Also, write a vacuous implementation of an inherited method is a possibility that the language allow:


Greetings.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As David says, it's not final so that you can overwrite it. You may want to have a thread class that works differently upon creating a thread; in that case, overriding that method is useful.

This should only very rarely be necessary, though. For your garden variety threads, don't extend Thread - implement Runnable: ExtendingThreadVsImplementingRunnable.
 
Bob Wheeler
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds logical.

Thanks guys.
Bob
 
Ranch Hand
Posts: 814
Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Bob

There is a start0() method call in start() method implementation of Thread.java source file which is declared private & native because of this I thought that the Thread class version of start() method behave differently than overrided version of start() method in sub class. Can anybody explain start0() private native method implementation in Thread.java so that we can understand difference in behaviour of start() method of Thread class and overrided start() method in subclass version of Thread class.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic