# hhl-threadpool-java **Repository Path**: DreamPro/hhl-threadpool-java ## Basic Information - **Project Name**: hhl-threadpool-java - **Description**: java实现线程池的jni调用,ubuntu16环境 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2020-12-22 - **Last Updated**: 2021-04-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # hhl-threadpool-java 执行调用java中的native方法,jni范调用run方法,ubuntu16环境 ### 设置本机 java_home export JAVA_HOME=/home/root0527/Desktop/openjdk/build/linux-x86_64-normal-server-slowdebug/jdk export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$PATH ### 生成 jni的.h文件 进到MyThread 所在的目录下 javac MyThread.java -h ./jni ### 把com_hhl_jni_thread_MyThread.h 拷贝到c代码目录中 ### 配置 CMakeLists.txt include_directories("/home/root0527/Desktop/openjdk/build/linux-x86_64-normal-server-slowdebug/jdk/include") 并且把jni_md.h 文件拷贝到 include目录下 ### 在c代码中执行 /usr/bin/gcc -shared -fpic -I/home/root0527/Desktop/openjdk/build/linux-x86_64-normal-server-slowdebug/jdk/include com_hhl_jni_thread_MyThread.c -o /home/root0527/Desktop/openjdk/build/linux-x86_64-normal-server-slowdebug/jdk/lib/libjni.so ### 设置jdk的vm options -Djava.library.path=/home/root0527/Desktop/openjdk/build/linux-x86_64-normal-server-slowdebug/jdk/lib ### 直接运行Application.java的main方法 出现下列情况即为成功 result : main say: 0 main say: 1 main say: 2 main say: 3 main say: 4 main say: 5 main say: 6 main say: 7 main say: 8 main say: 9