File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Marcus Mock exam 2 Threads

 
joy
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • 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
  • 0
  • send pies
  • 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.
 
Marcus Green
arch rival
Rancher
Posts: 2813
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Greg Whelan
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Kent Farnsworth
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • 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!
 
Fred Abbot
Ranch Hand
Posts: 300
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Eric Barnhill
Rancher
Posts: 233
Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got a question involving stop() on the SCJP last week.
Eric B.
 
maha anna
Ranch Hand
Posts: 1467
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic