This week's book giveaway is in the Java in General forum.
We're giving away four copies of Helidon Revealed: A Practical Guide to Oracle’s Microservices Framework and have Michael Redlich on-line!
See this thread for details.
  • 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Marcus Mock exam 2 Threads

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is no. 22 of Marcus Mock exam
What can cause a thread to stop executing?
1) The program exits via a call to System.exit(0);
2) Another thread is given a higher priority
3) A call to the thread's stop method.
4) A call to the halt method of the Thread class
My answers are only 1 and 3. but the given answer is 1,2,3.
A thread can stop executing if a thread is given a higher priority? I thought that if a thread is given a higher priority while another thread is running will only be moved to the ready state but it will not stop the currently running thread to stop executing.
Am I right?
regds,
joy
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thats my impression too, but before the exam.
From my previous discussions I have to believe that
this is not true. The reason is that the this is a
platform dependent issue. In most/some JVMs the thread
schedulers will stop the running thread if there is a
higher peiority thread. If you were thinking like me,
there is another qstn abt threads that has the same
principle. I go these two wrong when I attempted the test.
I don't remember the other one right now ....
Here is the previous discussion ...I was thinking of
revising this post ....thanks for re-posting.
Previous discussions
Regds.
- satya
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by joy:
This is no. 22 of Marcus Mock exam
What can cause a thread to stop executing?
1) The program exits via a call to System.exit(0);
2) Another thread is given a higher priority
3) A call to the thread's stop method.
4) A call to the halt method of the Thread class
My answers are only 1 and 3. but the given answer is 1,2,3.
A thread can stop executing if a thread is given a higher priority? I thought that if a thread is given a higher priority while another thread is running will only be moved to the ready state but it will not stop the currently running thread to stop executing.
Am I right?
regds,
joy


I got this exact question on the real exam and answered 1, 2, and 3. I got 100% on the thread section of the exam. Nuff said.
 
arch rival
Posts: 2813
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All the best Mock exams include a little explanation with the answers. Here is what that fine chap Marcus says as part of the answer to that question.
"Java threads are somewhat platform dependent and you should be carefull when making assumptions about Thread priorities.
On some platforms you may find that a Thread with higher priorities gets to "hog" the processor."
OK so not the best wording in the world, but you get the picture.
Marcus
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Re #3. Isn't the stop method deprecated in Java2? Does Sun have a policy somewhere relating to deprecated methods for SCJP?
I would have answered only 1 (and now that I've heard seen the writing on the board, 2 also).
 
Greg Whelan
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see there's been some discussion of stop() appearing on SCJP exam... but I haven't seen a definitive answer as to whether it's considered an acceptible answer.
http://www.javaranch.com/ubb/Forum24/HTML/001414.html
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just took the SCJP exam and I had a question like this on the exam. I suggest you do not read any more into the question then there is. The fact that the method is deprecated is not the point, it can still be used!
 
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the fact that STOP is a deprecated method should make a diffrence
since this the java 2 exam although it can be used and will compile with a warning is irrelevent as it is not part of the java 2 api which the test is supposed to be based on
 
Rancher
Posts: 241
Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got a question involving stop() on the SCJP last week.
Eric B.
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eric,
I didn't get any qstn involving any deprecated method.
Eric, since you got a qstn with dep.d method, why don't you put a full stop for this ongoing discussion. Not to discuss any real exam qstn. Just to assure that should we select the answer with deprecated method if at all it is eligible answer for the qstn.
Thank you.
regds
maha anna
 
There is no "i" in denial. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic