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!
Sun Certified Programmer for Java2 Platform scored 100%.
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)
<b>Sandeep</b> <br /> <br /><b>Sun Certified Programmer for Java 2 Platform</b><br /> <br /><b>Oracle Certified Solution Developer - JDeveloper</b><br /><b>-- Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java </b><br /><b>-- Object-Oriented Analysis and Design with UML</b><br /> <br /><b>Oracle Certified Enterprise Developer - Oracle Internet Platform</b><br /><b>-- Enterprise Connectivity with J2EE </b><br /><b>-- Enterprise Development on the Oracle Internet Platform </b>
Joined: Jul 14, 2001
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..
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.
Joined: Jul 14, 2001
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%.