• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Marcus green test#3, question #44

 
Christy Smith
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,
I am puzzled by the answer to this question.
Question is :
Question 44)
Given a reference called
t
to to a class which extends Thread, which of the following will cause it to give up cycles to allow another thread to execute.
1) t.yield();
2) yield()
3) yield(100) //Or some other suitable amount in milliseconds
4) yield(t);
Answer provided is:
Answer to Question 44)
Objective 7.1)
yield is a static method inherited from object and causes whatever thread is currently executing to yield its cycles.
2) yield()
I thought the answer would be 1, since t is a reference to Thread, and yield() is a static method of the Thread class. yield() might work if it is called in a subclass of Thread. Right??
 
Mark Brossard
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at:
http://www.javaranch.com/ubb/Forum24/HTML/004488.html
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic