我如何跟踪未知的线程/可运行的?

发布于 2024-09-19 10:18:20 字数 536 浏览 4 评论 0原文

我正在开发 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

人生戏 2024-09-26 10:18:20

您可以安装一个安全管理器,该管理器允许执行所有操作,但在请求启动线程的权限时会注销。

或者,您可以提供一个替换 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.

情释 2024-09-26 10:18:20

org/tritonus/midi/device/java/JavaSequencer.java 有以下代码:

protected void openImpl()
    {
            ...
            m_thread = new Thread(this);
            ...
            m_thread.start();
    }

所以这是一个需要查找的地方(但这仅回答了特定情况,而不是一般问题如何找出在哪里一般都会启动一个线程)。

在同一个类中还有其他地方调用了 this.start():在 setSequence(..)setTickPosition(..) 中>。但是,可能会在类外部调用 start()

org/tritonus/midi/device/java/JavaSequencer.java has the following code:

protected void openImpl()
    {
            ...
            m_thread = new Thread(this);
            ...
            m_thread.start();
    }

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: in setSequence(..) and setTickPosition(..). There could be calls to start() outside the class however.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文