• 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

Thread question?

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You have an application which executes the following lines:
Thread myT = new Thread();
myT.start();
Select all of the following statements that are correct.
a. The Thread myT is now in a runnable state.
b. The Thread myT has the NORM_PRIORITY priority.
c. The Thread will die without accomplishing anything.
d. The run method in the class where the statement occurs will br executed.


The answers are a and c.
Could someone please explain why?
I thought all Threads are created with the normal priority (5)
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A newly created thread gets the priority of its creator.
The same goes for its deamon status.
-Barry
 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't really agree that a is correct because of the word 'now'. Who's to say what state the thread is in 'now'. It could be runnable, running, or already dead.
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
c looks right as the run method of the Thread class does nothing, so the thread will die very soon after it starts.
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
whya only a and c, why not d "The run method in the class where the statement occurs will br executed".
This statement says that if run method exists in the same class then it will execute, which is true i suppose.
badri
reply
    Bookmark Topic Watch Topic
  • New Topic