File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Types of Lock in java object 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 "Types of Lock in java object" Watch "Types of Lock in java object" New topic
Author

Types of Lock in java object

Pankaj Patro
Ranch Hand

Joined: Apr 20, 2005
Posts: 32
hi,

What are the types of lock in java(like Object level, Class level lock).
and how these are used in the application.


Thanks & Regards,
Pankaj Patro
Vaibhav Chauhan
Ranch Hand

Joined: Aug 16, 2006
Posts: 115
Object level lock: this is the lock that any thread aquires over nonstatic synchronized method. Any thread can invoke the synchronized method for different object other than the object that has invoked the synchronized method.

Class level lock: this is the lock that any thread aquires over static synchronized method. No thread can invoke the synchronized method for any object until the first thread which is having the lock releases it.



We need not to worry about locks during coding, it is decided by compiler depending upon keyword static.

I know only two locks, if there is any other locks please respond with answer.


hope you got it.
Pankaj Patro
Ranch Hand

Joined: Apr 20, 2005
Posts: 32
thanks, I have got some Idea...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Types of Lock in java object
 
Similar Threads
Doubt in Thread Ques
Synchronized with example
Doubt in synchronized....
Clarification in Class Type's in Java
Class level lock versus Object level lock