ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

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
تم إضافة السؤال من قبل Mohd shahnawaz khan , Associate Project , Cognizant Technology Solution
تاريخ النشر: 2013/12/04
Usman Azhar
من قبل 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. 

 

ashim anand
من قبل ashim anand

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.

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟