Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread question?

 
Ryan Wilson
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • 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)
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A newly created thread gets the priority of its creator.
The same goes for its deamon status.
-Barry
 
Rory French
Ranch Hand
Posts: 97
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Badri Sarma
Ranch Hand
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic