aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Thread Q from Khalid Q.44 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Thread Q from Khalid Q.44" Watch "Thread Q from Khalid Q.44" New topic
Author

Thread Q from Khalid Q.44

Brian, Cavanagh
Ranch Hand

Joined: Oct 30, 2000
Posts: 70
Here's another one, which caused similar problems guys?
Which statements concerning the methods notify() and notifyAll() are true?
1. Instances of class Thread have a method called notify()
2. A call to the method notify() will wake the thread that currently own the monitor of the object.
3. The method notify() is synchronized
4. The method notifyall() is defined in class Thread
5. When there is more than one thread waiting to obtain the monitor of an object, there is no way to be sure which thread will be notified by the notify() method.
I know 3. False
4. False
But, I would be interested to hear what you guys think of the other options.
Cheers,
Brian
Brian, Cavanagh
Ranch Hand

Joined: Oct 30, 2000
Posts: 70
It's ok guys I got it.
1, 5 are true.
Nasir Khan
Ranch Hand

Joined: Nov 04, 2000
Posts: 135
Why 1 is correct?
I think instances of class Object have a method called notify()
please someone verify this.
Yamuna Pattathil
Greenhorn

Joined: Dec 03, 2000
Posts: 19
Thread class inherits the method from Object class. So 1 is also correct
[This message has been edited by Yamuna Pattathil (edited December 12, 2000).]
Michael Burke
Ranch Hand

Joined: Jul 29, 2000
Posts: 103
I'd agree with Nasir #1 is false.
Brian, Cavanagh
Ranch Hand

Joined: Oct 30, 2000
Posts: 70
Thread (like all objects) extends from Object, and therefore each instance has a notify(), wait() and notifyAll() method, as do any other object.
Look at this code:
String s = new String();
s.wait();
is completely valid.
Neha Gupta
Greenhorn

Joined: Dec 04, 2000
Posts: 9
I agree with Brain.
Answer 1 is correct.
Notify and NotifyAll are public methods and subclasses inherit from super.So 1 is correct.


Neha
Nasir Khan
Ranch Hand

Joined: Nov 04, 2000
Posts: 135
No 1 is correct in a sense that Thread extends Object.
I was confused because of the way wait() and notify() are used I mean they are used like object instance method ,not
like thread instance method.I'll be thankful if someone give more explaination on that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread Q from Khalid Q.44