I have a Java application using threads, which uses several Lock object instances to synchronize access to common resources.
Now as part of a performance measurement I want to measure the time spent by each thread in every lock. I have tried so far NetBeans profiler.
Netbeans profiler shows me the total wait time for a thread but it is impossible to know how much time in which lock the thread waited.
Which tool will you recommend for this kind of measurement?
Cheers
Depending on exactly what data you need, you can just get this information from within your Java program. For example, something like this will sample held locks 20 times a second for 100 seconds, creating effectively a map of lock > approximate time locked (number of “ticks” during which the given lock was being locked on):
Adapt to collect the data as you need it.
You can then start this going in a background thread e.g.: