What are the types of lock in java(like Object level, Class level lock). and how these are used in the application.
Thanks & Regards,
Joined: Aug 16, 2006
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.