Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

thread execution!

 
ashok khetan
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q.22 What can cause a thread to stop executing?(From Marcus mock2)
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?
how can the option 2) be right? The question states to stop the execution not to stop the thread temporarily.
ashok.
 
Geoffrey Falk
Ranch Hand
Posts: 171
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(1) is definitely right.
(2) I guess it depends on your definition of "stop executing" which is ambiguous IMHO. It oculd mean to temporarily take away CPU cycles from the thread, or to logically stop the thread. The designers of the Sun Java exam have worked hard to eliminate any linguistic ambiguity; so, as long as you understand the concepts of threading, you should not be troubled by mock questions such as this.
(3) The "stop" method is deprecated, so there will not be any questions about it on the exam.
(4) is wrong, because there is no "halt" method.
Geoffrey

------------------
Sun Certified Programmer for the Java 2 Platform
 
Ragu Sivaraman
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(1) is perfect
(2) I cant accept that
What if the OS thread scheduling is RoundRobin?(For ex: Windoze)
-Ragu
 
marilyn murphy
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question is
Q.22 What can cause a thread to stop executing?
not
Q.22 What will cause a thread to stop executing?
If a another thread has a higher priority, in certain systems it may cause the current thread to stop. The stop may be temporary or permanent (if System.exit is called for example).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic