Invoking time-consuming JNI task as a thread

前端 未结 4 2103
慢半拍i
慢半拍i 2021-02-10 20:10

I\'m having a tough problem with invoking a native function using JNI from a thread.

The native function is legacy code that performs a computation-intensive task. Since

4条回答
  •  庸人自扰
    2021-02-10 20:33

    My advice on using JNI is DON'T if you can possibly avoid it. The chances are that it will cause stability issues for you. Here are some possible alternatives:

    1. Recode the native library in Java.
    2. Write a wrapper command for the native library in C / C++ / whatever and run it using java.lang.Process and friends
    3. Turn the native library into a daemon and access it using Sockets.

提交回复
热议问题