How to debug Thread.start () in java

I am debugging a Java application in NetBeans IDE 8.0.2.

When a method is called Thread.start(), I cannot reach the method of run()this thread (although I set breakpoints in this method). However, sometimes he strikes the method, but sometimes not.

How can I use the method run()during debugging?

public class JavaApplication7 {

    public static void main(String[] args) {
        Mailthread1 mt1 = new Mailthread1();
        Thread pt = new Thread(mt1);
        pt.setName("Mailthread");
        pt.start();
    }
}

And Thread class:

class Mailthread1 implements Runnable {
    public void run() {
        System.out.println("Cant hit this line");
    }
}
+4
source share
1 answer

There are 3 types of breakpoints in JDWP: class, method, and string.

If your IDE cannot capture the line break point in println (), you can try the method breakpoint in reclaration run ().

, . , .

, IDE / JVM. .

+1

All Articles