*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Urgent plzzzzzz help!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Urgent plzzzzzz help!!" Watch "Urgent plzzzzzz help!!" New topic
Author

Urgent plzzzzzz help!!

himanshu kesarwani
Ranch Hand

Joined: Aug 27, 2008
Posts: 84

i am shocked after this question java is really very very unpredictable,its just compillers mood that decide what to run and what to not....
lookin at start(); method compiler forgets that its a thread and it should call run(); instead it prefered THE start();
..........!!
i cant bear it any more, on 1st april i am having scjp exam and such type of questions are making me nervous!!
but still i am determined...to beat scjp !!


SCJP 5
Treimin Clark
Ranch Hand

Joined: Nov 12, 2008
Posts: 757
Rules: UseAMeaningfulSubjectLine, EaseUp, QuoteYourSources
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41106
    
  45
What else would you expect if you override the Thread.start method? Its javadocs clearly mention that one of its purposes is to create a new thread and then call its "run" method.

This is a good example of why you should almost never (and certainly not here) extend Thread, but instead implement Runnable: ExtendingThreadVsImplementingRunnable


Ping & DNS - my free Android networking tools app
Abhi Kumar
Greenhorn

Joined: Sep 11, 2008
Posts: 24
hello himanshu kesarwani !!
Initially look at the code, you are creating the object of Th and not that of Thread class.
The compiler treats start() as a local method to the class Th , and invokes the start method.

If you create a Thread object and call the start method then you can see the run() method being invoked
Regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Urgent plzzzzzz help!!
 
Similar Threads
Generic type casting
How to cope with situations that should never occur?
Solve this thread question!! confused!!
how to create an object array? not Object
Synchronizing between two threads, one implements Runnable the other extends Thread