aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes ExamCram - Threads 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 "ExamCram - Threads" Watch "ExamCram - Threads" New topic
Author

ExamCram - Threads

Cathy Song
Ranch Hand

Joined: Aug 24, 2003
Posts: 270
You have an application that executes the following line:
Thread myT = new Thread() ;
Which statements are correct? [Check all correct answers.]
A. The Thread myT is now in a runnable state.
B. The Thread myT has the priority of the Thread that executed the construction statement.
C. If myT.start() is called, the run method in the class where the construction statement appears will be executed.
D. If myT.stop() is called, the Thread can later be started with myT.start() and will execute the run method in the Thread class.
Answers: B
Why not C also?
Thanks.
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 804
Hi, Cathy -
It's the run() method of the runnable object that gets called. When you create and start a thread, you either pass it the runnable object or the object creating the thread must be runnable (extend Thread or implement Runnable) and have a run() method that gets called. If these conditions don't exist, Thread.run() is invoked, which does nothing.
From the API for Thread:
If this thread was constructed using a separate Runnable run object, then that Runnable object's run method is called; otherwise, this method does nothing and returns.


Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: ExamCram - Threads
 
Similar Threads
q on threads
Thread Question on Exam Cram Mock
thread question from java cram
Thread Question
exam cram