It's not a secret anymore!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes A question about thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "A question about thread" Watch "A question about thread" New topic
Author

A question about thread

avseq anthoy
Ranch Hand

Joined: Apr 27, 2004
Posts: 102
Thread myThread = new Thread();

A.The thread myThread is now in a runnable state
B.The thread myThread has priority is 5
C.On calling the start() method on myThread,the run method in the Thread class will be execute
D.On calling the start() method on myThread,the run method in the calling class will be execute

Answer:C

why B is wrong?


My Way,My Pace
Anil Hulikal
Greenhorn

Joined: Apr 02, 2004
Posts: 29
I think within the context of this question, a thread of execution has not begun; only a Thread object has been created. This object may very well have a field value of priority = 5. However, the wording of the given option is �The thread myThread has priority is 5�. Probably by �thread�, they are referring to a thread of execution. So, since the �thread of execution� has not begun yet, without a call to the start method, it would be inappropriate to say that it has a priority of 5.

Regards,
Anil


Just stay focused.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12671
    
    5
As you can easily determine by reading the java.lang.Thread JavaDocs - a newly created Thread has the same priority as the creating Thread.
Bill


Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A question about thread
 
Similar Threads
start() in java
Thread Question---start()
Thread's start() and run()
Thread
why run() method in Runnable interface is not called ?