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.
(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
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).