Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

threads

 
vipin bhatia
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am dissapointed no one has even tried answering my question with the subject "wait and notify with classes" can someone help me since i have my jcp on 2nd of august. i tried looking through the API, java tutorials, java language specifications but no one has mentioned how to deal with it.
help!
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vipin,
What's your question on wait and notify?I normally see to it that none of the posts in this forum go unanswered.I will try my best to answer your question
-- Sandeep
SCJP2,OCSD(Oracle JDeveloper),OCED(Oracle Internet Platform)
 
vipin bhatia
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! Sandeep,
My question was ->
I have a class with two static synchronized methods so they
will use the lock of the class right? Now if i want to use
wait and notify from within these methods, i can not because
they are non static methods being called from static
methods.
Is thier anyway this can be solved, i.e. imagining a Queue
problem where add and remove are static menthods working on
static array.
How can we synchronize the producer and consumer on the lock
of the class using wait and notify.
hope me not repeating some recently asked question if so
kindly point me towards it.
thnx.
I have finally found out that this can be solved by using MyClass.class.notify() & MyClass.class.wait() but there is no mention of this Class literal class in the API, can you guide me where can i find more info on it..
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13045
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Class is a regular Java class in the java.lang package.
Bill
 
Ragu Sivaraman
Ranch Hand
Posts: 464
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Batia,
If you refer java.lang API tree you will see Class
Class inherits from Object there by you get wait and notify.
Class has no public constructor. Instead Class objects are constructed automatically by the Java Virtual Machine as classes are loaded and by calls to the defineClass method in the class loader
So its already there for use.

HTH
 
vipin bhatia
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
guys what i was asking was not about the class "Class" but the literal "class" which is a class literal but i guess the right person to answer would be jim yingst go gave me this answer in the first place in the discussion group of jchq.net.
anyways i wrote my jcp today and scored 100%.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic