This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JavaCaps Question 41

 
bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is taken from the mock exam at: http://www.javacaps.com/sjpc_mockexam.html
I beleive that this answer is wrong, wanted to get others opinion.

The answer given is A,B, and D.
I agreed on B and D, but with A, I thought the start() method makes it eligible to run, but it is the schedular that makes it run.
 
Kathy Rogers
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bill,
I agree with you - it is wrong. RHE refers to needing "a run() method for the thread scheduler to invoke" (p.203). I think it's trying to get at the fact that you don't have to code a direct call to run() but start() just tells the scheduler that the thread's eligible to run. Start() can't call run because when it actually gets to run is system dependent. In that sense it's a bit like garbage collection - you can make something available for garbage collection but when it's collected depends on how the system schedules stuff.
Kathy
 
Ramesh Natarajan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with your choices A,B. But I didnt understand that the option D (A stop() method kills the currently running Thread). Give your explanation.

 
bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The stop() method is now deprecated, so you won't get that on the 1.2 test. It has been replaced by the interrupt() method, but the purpose of the stop() method was to stop the currently running thread.
 
Cheryl Gray
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the link Bill.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!