Terminate a thread which is running a native code

前端 未结 5 1685
既然无缘
既然无缘 2020-12-16 04:12

In my application I have a wrapper over some native code, which is called via JNI bridge. This native code needs to be executed in separate thread (parallel processing). How

5条回答
  •  既然无缘
    2020-12-16 04:54

    You could wrap this single call to JNI method into a separate Java application and then fork another java process with java.lang.Process. Then you can call Process.destroy() to destroy that process on the OS level.

    Depending on what your environment is and other considerations you might have to do some tricks to find out how to find java executable, especially if you are building some redistributable software which could be run on different platforms. Another issue would be for you the IPC, but that could be done using Process's input/output streams.

提交回复
热议问题