Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有一种工具可以用来查看代码的哪些部分在哪个线程中(颜色代码之类的)?我最关心的是 EDT,但是每隔一行编写 isOnEventDispatchThread()-ish 命令,然后在程序运行时跟踪它的输出是乏味且耗时的。
我看到的主要问题是可以从任何线程调用的代码,例如构造函数。但是,您可以在运行时使用 Eclipse 的调试器。只需在调试器中运行程序,直到出现断点或手动暂停,然后查看通常位于左上方的“调试”视图。您会看到线程并且可以选择其中一个跳转到它的位置。