avn,
It is recommended that you post all
thread and synchronization questions in the Threads forum.
To answer your question let us define an Object. An Object is an instance of a Class. Thus the Class and its Object are two different entities. The question specifically asked is how many locks does an Object have and since each instance of Object and its subclasses possesses a lock, there is only one lock associated per Object.
However there is also another lock, the Class Lock. The class lock is not associated with a Object but on the Class.
Note:
What object does non-static synchronized methods use for locking?
Non-static synchronized methods synchronize on the instance (this) of the class.
What object does static synchronized methods use for locking?
Static synchronized methods synchronize on the class object (this.getClass()) of the class.
------------------
Regds.
Rahul P. Mahindrakar