问题描述
我有3个班级:
创建线程的主类.
Thread t = new Thread(new Class1)
Thread t1 = new Thread(new Class2)
t.start()
t1.start()
Class1实现Runnable
Class1 implements Runnable
Class2实现Runnable
Class2 implements Runnable
在netbeans中,如何同时调试Class1和Class2?
In netbeans, how do i debug through Class1 and Class2 at the same time?
推荐答案
您可以将断点放置在Class1
和Class2
中的每个run()
方法内.在Debugging
选项卡中,您可以看到所有的Threads
.
You can place the breakpoint inside each of the run()
methods within Class1
and Class2
. In the Debugging
tab you can see all the Threads
.
当您单步执行某个线程并在另一个线程中命中断点时,IDE会为您提供切换到另一个线程或继续单步执行当前线程的选项.如果您在调试"窗口中查看,您会看到当前线程(Thread_Jirka)在页边空白处显示为绿色.通过击断点(Thread_Roman)调用通知的线程由黄色条指示,并且线程图标指示该线程已被断点挂起.
When you are stepping through a thread and a breakpoint is hit in another thread, the IDE gives you the option to switch to the other thread or continue stepping through the current thread.If you look in the Debugging window you can see that the current thread (Thread_Jirka) is indicated by a green bar in the margin. The thread that invoked the notification by hitting the breakpoint (Thread_Roman) is indicated by a yellow bar and the thread icon indicates that the thread is suspended by a breakpoint.
这篇关于如何在NetBeans中同时调试多个线程/可运行对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!