aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes overiding start Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "overiding start" Watch "overiding start" New topic
Author

overiding start

sun par
Ranch Hand

Joined: Oct 03, 2002
Posts: 257
suppose we overide start() method in a Thread and we have also a run() method,

How do we start the thread?
Thanks


Sunita<br />SCJP 1.4
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
You are not supposed to override the start method as it is natively implemented. If you do override, you'll have no way of starting the thread unless you call super.start() within the overriding start method.


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
sun par
Ranch Hand

Joined: Oct 03, 2002
Posts: 257
Thanks Valentin
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
If you are not supposed to override start, why isn't it declared final?
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
That's a very good question Marlene
I think people at Sun did not want to prevent people from overriding start(). Although, they should update the doc and say that it is a very bad practice to do so, and that if overriding is not an option not to forget to invoke super.start() somewhere in the body of the overriding method.
Kathy could maybe shed some light on this...
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: overiding start
 
Similar Threads
threads and uncaught exceptions
join() method in Thread doesn't work as expected
confusion in join()
threads
wait() and notifyAll()