How to check if a thread holds lock on a particular object in Java? Example

Think about a scenario where you would have to find at the run time whether a Java thread has a lock on a particular object e.g. find out whether thread NewsReader has a lock on a NewsPaper object or not? If these questions came in any core java interview then I would automatically assume that there could be at least two answers one is the hard-earned raw answer which programmer would like to figure out based on fundamentals and the other could be some rarely used API calls that are available in Java, by the way, this is actually asked to me in an interview of one of the biggest global Investment bank.

تعليقات

المشاركات الشائعة من هذه المدونة

Why use Underscore in Numbers from Java? Underscore in Numeric Literals Example

3 ways to convert String to Boolean in Java? Examples

Coursera's TensorFlow: Advanced Techniques Specialization Review [2022]