weixin_39620653 2020-11-22 02:47
浏览 0

Each time media is played a new thread is created, but never destroyed

Using JVisualVM shows the live thread count go up by one each time media is played. The thread never gets destroyed.

该提问来源于开源项目:caprica/vlcj

  • 写回答

8条回答 默认 最新

  • weixin_39620653 2020-11-22 02:47
    关注

    When invoking stop, all that happens is the native media_player_stop method is called. When invoking play, the native media_player_play method is called.

    Each time play is called, a new thread is created. The old thread just seems to keep running.

    This is related to setting the callback thread to be in "non-detach" mode for JNA's callback mechanism.

    If instead the thread detaches, then each callback invocation gets a new thread (so thousands of threads can be created). At least in that case there are no spurious threads hanging around.

    Anyway, the point is, this is due to some interaction between the native thread between stop and display. vlcj is not actually doing anything with threads itself at this point.

    评论

报告相同问题?