I'm studying for the
SCJP exam (I'm taking it 2/8/02) and have some
thread questions.
QUESTION 1: Can threads execute concurently (at the exact same nano-second)?
-or-
Do threads take turns executing?
-or-
Does it depend on the OS?
QUESTION 2: Does a call to a thread object's yield method relinquish an object lock if it is called while executing an object's synchronized method?
Answer: Okay I got this one on my own. The Java API documentation indicates that yield() does not release a lock on an object. QUESTION 3: Does Thread.sleep(i) cause the current executing thread to relinquish a lock on an object if the thread happens to be executing an object's synchronized method?
Answer: I got this one as well. The Java API documentation indicates that sleep() does not release a lock on an object. QUESTION 4: While a thread is executing an object's synchronized method it goes into a blocked state. Does the thread give up its lock on the object it was using?
QUESTION 5: Does a thread always leave the running state when it performs an IO operation like:
QUESTION 6: Let's say an object's synchronized method calls wait() but never calls notify() or notifyAll(). Also assume that the threads that use this object are non-daemon threads. Would this cause the program to run forever?
Thanks!
Bob
[ January 30, 2002: Message edited by: Bob Graffagnino ]
[ January 30, 2002: Message edited by: Bob Graffagnino ]