Why must my JNI native code be compiled and linked with the -pthread option?
All C/C++ code that uses POSIX threads must be compiled and linked using the C/C++ -pthread option. Otherwise, the resulting program will not execute properly. The Virtual Machine uses POSIX threads. Hence, any JNI native code that uses the JVM uses POSIX threads by default, and so must be compiled and linked using the -pthread option. For more information about the -pthread option, please see the C/C++ man pages.