File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A question about thread

 
avseq anthoy
Ranch Hand
Posts: 106
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Anil Hulikal
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13045
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic