我如何跟踪未知的线程/可运行的?
我正在开发 Java MIDI 应用程序。
我一直坚持调试异常,该异常在歌曲结束时调度。正如我所期望的:应用程序正在播放,每次我检查序列刻度位置以在应用程序播放行中表示它,就像播放器一样。
所以我想知道如何获取源代码或该线程开始运行的点?
下面是异常输出:
Exception in thread "Thread-23" java.lang.IllegalStateException: Sequencer is not open
at org.tritonus.share.midi.TSequencer.checkOpen(TSequencer.java:296)
at org.tritonus.share.midi.TSequencer.stop(TSequencer.java:256)
at org.tritonus.midi.device.java.JavaSequencer.run(JavaSequencer.java:291)
at java.lang.Thread.run(Unknown Source)
I'm developing Java MIDI application.
And I have stuck with debugging of exception, which dispatching at the end of song. As I'm expecting: the application is playing and each time I'm checking the sequence tick position to represent it in application playback line, like as player.
So I want to know how could I get the source or the point where this Thread start running?
Below is an exception output:
Exception in thread "Thread-23" java.lang.IllegalStateException: Sequencer is not open
at org.tritonus.share.midi.TSequencer.checkOpen(TSequencer.java:296)
at org.tritonus.share.midi.TSequencer.stop(TSequencer.java:256)
at org.tritonus.midi.device.java.JavaSequencer.run(JavaSequencer.java:291)
at java.lang.Thread.run(Unknown Source)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以安装一个安全管理器,该管理器允许执行所有操作,但在请求启动线程的权限时会注销。
或者,您可以提供一个替换 Thread 实现,并使用 bootclasspath 选项将其放在 rt.jar 中的实现之前,并让此替换 Thread 在其构造函数中记录其名称和堆栈跟踪。
You could install a security manager which allows absolutely everything, but logs out when it's asked for permission to start a thread.
Or, you could provide a replacement Thread implementation and put it ahead of the one in rt.jar by using the bootclasspath options, and have this replacement Thread log its name and stacktrace in its constructor.
org/tritonus/midi/device/java/JavaSequencer.java
有以下代码:所以这是一个需要查找的地方(但这仅回答了特定情况,而不是一般问题如何找出在哪里一般都会启动一个线程)。
在同一个类中还有其他地方调用了
this.start()
:在setSequence(..)
和setTickPosition(..)
中>。但是,可能会在类外部调用start()
。org/tritonus/midi/device/java/JavaSequencer.java
has the following code:So that's one place to look for (but that answers only the specific case, not the general question how to find out where a thread is started in general).
There are also other places in the same class where
this.start()
is called: insetSequence(..)
andsetTickPosition(..)
. There could be calls tostart()
outside the class however.