File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes threads 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 "threads" Watch "threads" New topic


vipin bhatia
Ranch Hand

Joined: Jul 14, 2001
Posts: 31
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.

Sun Certified Programmer for Java2 Platform scored 100%.
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
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

Joined: Jul 14, 2001
Posts: 31
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
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.
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

Joined: Mar 22, 2000
Posts: 13037
Class is a regular Java class in the java.lang package.
Ragu Sivaraman
Ranch Hand

Joined: Jul 20, 2001
Posts: 464
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.

vipin bhatia
Ranch Hand

Joined: Jul 14, 2001
Posts: 31
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
anyways i wrote my jcp today and scored 100%.
I agree. Here's the link:
subject: threads
It's not a secret anymore!