1) Compilation and run but no output 2) Compilation and run with the output "Running" 3) Compile time error with complaint of no Thread target 4) Compile time error with complaint of no access to Thread package The answer 2 is absolutely right. But I think the answer 1 might be right, too. When thread's start() method is called, in theory, it registers to thread scheduler and ready to run.If I am wrong, please correct me.
Edited by Corey McGlone: Added Code Tags [ April 04, 2003: Message edited by: Corey McGlone ] [ April 04, 2003: Message edited by: josie chen ]
Executing this program will always result in the output "Running" being displayed. Once you've started your thread, the application can not terminate until that thread has completed. Had that thread been made a daemon thread, then either of the first 2 answers could be correct. Corey
josie, may I suggest that you give a hint of what your question is about in the Topic header. For example, for this one, instead of "Who can answer me?", you might say "Thread question" or "When does the thread run"
corey, could you elaborate / explain your statement.. I am assuming you mean to say change the thread to daemon before starting the thread.. If a thread is changed after it has started then a IllegalStateException gets thrown... And a daemon thread in this case would not have been an actual thread, hence run would not be executed for it.. Am I right thanks