문제

I am trying to reduce the lock contention on a particular code-path in my application. To identify code with high lock contention, I connect YourKit to my application and use the "Monitor" tab and see acquiring which locks have caused the thread I care about to block. My eventual aim is to have no red dots for this thread in the "Thread" tab in YK GUI.

Often the contention arises from read/read locking using an intrinsic lock, so those can be improved by using a ReentrantLock instead of the intrinsic lock. Indeed when I tried this, YourKit reported lower contention. Is that information reliable? Does YourKit report usage of ReentrantLock's correctly?

I am using YourKit 8.0.24 on Solaris 10 with Sun 1.6u18 32-bit JVM.

도움이 되었습니까?

해결책

Looks like YourKit, as of now, does not report ReentrantLocks as blocked in the "Thread" tab.

다른 팁

Instead of following a locking-approach try to design your application be lockfree. With volatile variables and the classes in java.util.concurrent you can often write algorithms that are lockfree and therefore have no lock contention.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top