• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

A question about thread

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
I'm so happy! And I wish to make this tiny ad happy too:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic