a. Exiting from a synchronized block b. Callling the main method on an object c. Calling the notify method on an object d . Calling a read method on an InputStream object e. Calling the setPriority method on a Thread object I found this questionary from a SJCP studying site. I think answer is can be all. a. Exiting sychronized block means that the thread releases its lock, not stop executing. c. Wait () can stop thread executing not notify() or notifyAll() d. when a thread tries to read or write from or to stream and those activities were delayed because of ,in example, sluggish stream rate , the thread stop executing(actually it is blocked) until the delay goes away. So, if stream is not delayed, thread process doesn't stop. e. I heard that setPriority can change the thread's status and might stop the current thread. However, I heard that this process is platform-dependant. OS which use pre-emptive process such as Solaris follows this rule but OS which has a time-slicing architecture does not.
Can someone check if I'm right for all of these explanations? In addtion, I don't know what it means to call main method on an object. Can you expain me what it is calling main method? Because I've never seen this before. And effect on thread running. Thank you in advance.
Hi Woo, By 'calling the main method of an object' I think they are referring to calling the <code>public static void main(String args)</code> method. Hope that helps. ------------------ Jane Griscti Sun Certified Programmer for the Java� 2 Platform
But, why do we need to call the main() method, though it automatically runs when JVM starts? Is there any situation to call the main() method intentially? And What does it do to thread precess by calling the main method?
Joined: Aug 30, 2000
Hi Woo, I've never run into a situation where it was necessary to call <code>main()</code> explicitly. Just tried it and found it compiles fine but ends up putting you in an endless loop that creates StackOverflow errors; so not something I would advise using in any code. So I guess it won't stop a thread ------------------ Jane Griscti Sun Certified Programmer for the Java� 2 Platform