I am posting this again 2. Under which circumstances will a thread stop A. the method waitforId() in class mediaTracker is called B. the run() method that the thread is executing ends C. The call to the start() method of the Thread object returns D. The suspend() method is called on the Thread object E. The wait method is called on the Thread object My understanding A) I tried to track down the waitForId() method, which calls some other methods, which call some method of the toolkit class, which are supposed to load the image. So untill the Image is loded the thread waits. If the thread is waiting, then it is not running so it has stopped (running).True. B)The run method execution ends. The thread stops executing because there is nothing to execute, so it stops ( running).True C) The start() method doesnt wait for the run method of the new thread to finish execution. start() method returns even if the thread of execution started by it is still executing.False. D)Suspend Method is called on the new Object.(Do we need to know this for the exam?).By definition suspend Method will stop the thread untill it is resumed. True. E)Wait method will also stop the thread from running, Untill it is notified by some other thread.True My choices are not accepted by the Mughal Test.(It says only b is correct). I am sure this question has been discussed before, but I still havent come across a definitive answer. Kindly tell me link to some previous discussion of this question.
[This message has been edited by mohit joshi (edited October 06, 2000).] [This message has been edited by mohit joshi (edited October 07, 2000).]
why don't you search for this topic in this forum. There has already been lots of discussion on this topic. PLease go thro it u'll find it very helpful. Also, search for user & daemon threads. These topics are also covered in the exam.
Its nice to understand the various "phases" a thread can have. Like "running/runnable", "blocked", "dead". Methods like waitforId(), wait(), sleep(), suspend() and the i/o methods actually "blocks" the thread from running, ie. its waiting for some events to happen, so that it can resume its run.The scheduler won't consider the "blocked" thread, and its not occupying the CPU, but the thread is alive. A thread successfully finishes execution when it returns from the run() method, and the thread is considered as "dead".
Hi everybody! I put this small table to be discussed and corrected: (later inserts: I do not know why there are so much blank space before table, please, scroll the page down) What may/can/will stop a running thread?
I think what the Question's author meant was : when will the thread be dead. He felt free to use the term stop, because the deprecated method stop throws a ThreadDeath exception resulting in thread death. How ever the word "stop" is used in many different contexts ( in sun's documentation also ).Here is an part of text that explains why stop was deprecated: "What should I use instead of Thread.stop? Most uses of stop should be replaced by code that simply modifies some variable to indicate that the target thread should stop running....". so in present terminology stop is not equivalent to a thread dying.It could also mean "stop running". This is my interpretation.