Is there a way to suspend all business-logic execution threads of Java process when execution hits some method?
If it is not possible via external configuration is there any method call to embedd into application to achieve desired result?
Is there a way to suspend all business-logic execution threads of Java process when execution hits some method?
If it is not possible via external configuration is there any method call to embedd into application to achieve desired result?
According to how to profile application startup with visualvm I can start application with
-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y
to stop execution on app startup.
May be it would be possible to set breakpoint and move to interesting app state and then attach with profiler and start app again.
Another option is to start with Java agent: https://visualvm.github.io/startupprofiler.html
One solution is the place this code right before the method you want to debug:
System.out.println("Press Any Key To Continue...");
new java.util.Scanner(System.in).nextLine();
This waits until you press enter, so you have time to attach your debugger.
Another method is to use the IDE Netbeans, which contains a debugger and allows you to set breakpoints anywhere.