File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes Why isn't Thread's start method final? 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 » Java » Threads and Synchronization
Reply Bookmark "Why isn Watch "Why isn New topic
Author

Why isn't Thread's start method final?

Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
This is a follow-on question from a recent SCJP topic.

Why is the start method in class Thread not final?

All sorts of problems can arise from overriding start() because the method runs in the context of the calling thread and not in the context of a newly started thread until the "real" Thread start() method is invoked.

Thanks,
-Barry


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
I think just because sometimes we need to get some work done on a thread startup. Can't say more.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24056
    
  13

It's true that you could override start() and do something useful before or after calling super.start(), but really, I'm sure the reason is that the guys who write Thread didn't think of it. Sun has always been loath to change existing APIs in ways that would break existing user code, and so if this wasn't final originally, they won't make it final now.

The core APIs are full of this kind of stuff. Remember that the java.lang classes are some of the very oldest Java code in existence, and remember how your Java design skills improve with practice over the years!


[Jess in Action][AskingGoodQuestions]
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

So we can make money debugging other peoples mistakes
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why isn't Thread's start method final?
 
Similar Threads
My Confusion About Thead
Thread start() method
Thread /Runnable
Thread.start()
Answering Strategy