I need to determine which locks are the most-contended-for in my application code. What free tools can I use to determine this ?
you can use jconsole or jstack both in the bin directory of your JDK. The jconsole in particular allows you to connect to your process and monitor the threads including which resources they have locked, and it can help you identify a deadlock state.
The JDK has some built-in support - under unix, kill -3 the process, under windows, ctrl-break. This will display a complete thread dump, followed by any deadlocks detected. Plus, in the thread dusmp you can see what threads own what locks, and compare them to each other.
You can also view this in eclipse's debugger. In the Debug view, use the little down-triangle menu on the view toolbar to turn on "Java->Show Monitors".
When you suspect a deadlock, pause the application (select the application in the debug view and press the pause button on the debug view toolbar) and if there's a deadlock, the blocking threads will turn red. If you expand those threads you can see the lock contention.
If you own the code, you could create/look for a Lock implementation which gathers contention statistics. If not, try the tools suggested in the other posts.