Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

Can we call one synchronized method in another synchronized method with in the same class in java? if yes then how it will work ?

user-image
Question ajoutée par Mohd shahnawaz khan , Associate Project , Cognizant Technology Solution
Date de publication: 2013/12/04
Usman Azhar
par Usman Azhar , Technical Assocaite(Programmer) , Tech Mahindra Ltd

Yes, you can use it , Java uses concept of re-entrant lock, once your thread gets a lock holder object, it need not wait for the lock again, and can execute the synchronized method within a synchronized method. 

 

Yes , we can call any number of synchronized method within any synchronized method , it will work as stack how normal method works because when we make any method as synchnonized then lock is over class and thread which owns this lock is running all these methods so there is mens of conflict..

hope u get the answer.

More Questions Like This

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?