Using the following textbook thread wait/notify example, is there a tool (Eclipse plugin?) that tracks which thread locks on which object while stepping through and debugging? A tool that visually displays the connections in some way would be ideal if possible.
public class ThreadA {
public static void main(String[] args) {
ThreadB b = new ThreadB();
b.start();
synchronized (b) {
try {
System.out.println("Waiting for b to complete...");
b.wait();
} catch (InterruptedException e) {
}
System.out.println("Total is: " + b.total);
}
}
}
class ThreadB extends Thread {
int total;
public void run() {
synchronized (this) {
for (int i = 0; i < 100; i++) {
System.out.println(i);
total += i;
}
notify();
}
}
}