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 Obtaining locks Static syncronized methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Obtaining locks Static syncronized methods" Watch "Obtaining locks Static syncronized methods" New topic

Obtaining locks Static syncronized methods

mansoor iqbal
Ranch Hand

Joined: Aug 14, 2000
Posts: 91
Mughal says:
Classes also have class-specific moniors which is is analogous to the object monitor. Such a monitor is actually a monitor on the Class object of the class
what is the difference between obtaining a lock on an object and getting a lock on the class ...??

Joined: Mar 02, 2001
Posts: 7
The lock is similar with variable. A lock of a object is realted to the instance , if you have many objects of the same class in program ,they will monitor independent locks owned by themselves;But the class lock is only one which is shared by all instance. The lock of class is analogus to the static variable.
Do I say it clear?
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please choose a new name which meets the requirements.

"JavaRanch, where the deer and the Certified play" - David O'Meara
Ishaan Mohan
Ranch Hand

Joined: Jan 20, 2001
Posts: 115
Hi Mansoor,
Check the Maha's Page and see the discussion on thread. You will find very good examples and explanation there.
It is sorta covered in the JavaRanch Style Guide.
subject: Obtaining locks Static syncronized methods
It's not a secret anymore!