Hello everyone,


I want to know which method owns the lock of a specific object (some of my methods are blocked because they can not achieve the lock of a specific object, and I am wondering which method owns the lock to solve the deadlock issue). Does anyone know how to get the information?


Thanks in advance,
George

The object that first uses the object in synchronised code owns the lock.
There's no easy way to find out what that is, you'll need to diagnose your code to figure out in what places objects are used in a concurrent way and then figure out a means to deconflict them.

Better of course is to design your code from the start to make deadlock impossible ;)

Thanks jwenting,

The object that first uses the object in synchronised code owns the lock.
There's no easy way to find out what that is, you'll need to diagnose your code to figure out in what places objects are used in a concurrent way and then figure out a means to deconflict them.

Better of course is to design your code from the start to make deadlock impossible ;)

Your reply is very helpful. I think you a very experienced developer from your reply. Can you provide me more detailed skills/tricks dealing with how to find out deadlocks?


regards,
George

Thanks for all the people who helped me on this thread.


regards,
George

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.