• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Thread Q from Khalid Q.44

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's ok guys I got it.
1, 5 are true.
 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why 1 is correct?
I think instances of class Object have a method called notify()
please someone verify this.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd agree with Nasir #1 is false.
 
Brian, Cavanagh
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with Brain.
Answer 1 is correct.
Notify and NotifyAll are public methods and subclasses inherit from super.So 1 is correct.
 
Nasir Khan
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic