Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Why isn't Thread's start method final?  RSS feed

 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So we can make money debugging other peoples mistakes
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!