notify() in threads

Hi , Here is a Q from a mock exam Which of the following are true. 1) notify() is in Thread class. 2) notify() is a synchronized method. 3) notify() puts a thread from lock state to waiting . OF these which are true. I know that notify(), notifyall() and wait() are the methods of Object class. Also notify() is a native method. Can any body please give an answer for this. Thanks in advance.

1) notify() is in Thread class. 2) notify() is a synchronized method. 3) notify() puts a thread from lock state to waiting . None of them is true. notify() is a method defined in Object. (Although you may argue that Thread has inherited this method) notify is not a synchronized method. (It just must be run in a synchronized method) notify puts a thread from waiting to ready. (If it can acquire the lock, else it will go to block state)

madhuri vl
Ranch Hand

Joined: Jan 17, 2001
Posts: 86

posted Feb 27, 2001 12:07:00

0

Hi wong, Thankyou very much. Can you please clear one more . The methods of thread class are run(), start() ,getpriority() right.