Java Programming - Threads - Discussion
Discussion Forum : Threads - General Questions (Q.No. 15)
15.
Under which conditions will a currently executing thread stop?
- When an interrupted exception occurs.
- When a thread of higher priority is ready (becomes runnable).
- When the thread creates a new thread.
- When the stop() method is called.
Answer: Option
Explanation:
The statements (2) and (4) makes currently executing thread to stop.
Discussion:
6 comments Page 1 of 1.
Thomas said:
1 decade ago
I think this question and answer will confuse lerners.
My opinion is first: when an other thread with higher priority becomes runnable the vm might stop the executing of the currently running thread.
Second: the stop method is marked as deprecated so no question should base on it.
My opinion is first: when an other thread with higher priority becomes runnable the vm might stop the executing of the currently running thread.
Second: the stop method is marked as deprecated so no question should base on it.
Stinger said:
1 decade ago
stop method is deprecated and considered dangerous to use.
Ainul Habib said:
1 decade ago
Hi !
Deprecated methods should not be in practice test, because in later version the method itself can be removed. 'stop' method in this case should never be used to stop any thread, in-fact it should be handled differently
Deprecated methods should not be in practice test, because in later version the method itself can be removed. 'stop' method in this case should never be used to stop any thread, in-fact it should be handled differently
F J said:
1 decade ago
#2 is not true on a system with an multiprocessor machine. When a thread of higher priority becomes runnable, it will start executing, but that does not mean the current thread will stop.
Kalman said:
10 years ago
I'm sure that stopping a thread and putting it into the ready state in favor of a higher priority thread are completely different things.
Groumpf said:
10 years ago
What "a currently executing thread stop" means?
For me, when no instruction of the runnable will ever be executed.
But when a context switch comes, the thread is paused, not stopped.
For me, when no instruction of the runnable will ever be executed.
But when a context switch comes, the thread is paused, not stopped.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers