How can you visually imagine which threads are blocked for which objects in Java during debugging?

Using the following textbook wait / notification example, is there a tool (Eclipse plugin?) That keeps track of which thread blocks which object during transition and debugging? A tool that visually displays 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();
        }
    }
}
+3
source share
1 answer

Eclipse . , . " ", , . "Java | ".

+5

Source: https://habr.com/ru/post/1766464/


All Articles