Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

A question about thread

 
Ranch Hand
Posts: 108
  • 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?
 
Greenhorn
Posts: 29
  • 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
 
Author and all-around good cowpoke
Posts: 13078
6
  • 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
 
The knights of nee want a shrubbery. And a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic