我的java主程序通过调用一个C++库来完成相应的工作。用jni接口来访问C++ dll。jni接口写在一个名为Magicube的类中。Magicube的定义如下:
package nari.pmds.simulator;/**
 * Magicube PMDS Simulation Platform
 * @author xdl2000
 * @version 1.0.0
 *
 */
public class Magicube {

static
{
System.loadLibrary("pmds_core");
}
         ...
         
         //其中的一个接口函数
         public native boolean hasMustSubmitOrPopups(int iSimulator);
}
现在是这样的,我的主程序调用完magicube的一个native method之后,另起一个新线程访问magicube.hasMustSubmitOrPopups(int iSimulator);我的线程类是这样定义的:
package nari.pmds.server;import nari.pmds.client.PMDS;
import nari.pmds.simulator.Magicube;
public class CheckWindowThread extends Thread {

/* 运行标志 */
private boolean runflag = true; /* 暂停标志 */
private boolean paused = false;

         /* Magicube!! */
private Magicube m = new Magicube(); public CheckWindowThread() {

} /**
 * 重载Thread.run()函数,当线程被Start时自动调用
 */
public void run() {
while (runflag) {                           /* 在这里调用的jni接口!!! */
boolean b = m.hasMustSubmitOrPopups(PMDS.project.getISimulator());
System.out.println("CheckWindowThread running... hasMustSubmitOrPopups? " + b);
try {
sleep(1000);
} catch (InterruptedException e) {
System.out.println("sleep::" + e);
}
synchronized (this) {
try {
if (paused)
wait();
} catch (InterruptedException e) {
System.out.println("wait::" + e);
}
}
}
System.out.println("CheckWindowThread over...");
}


/**
 * 继续运行线程
 */
public synchronized void setResume() {
paused = false;
notify();
}

/**
 * 暂停线程
 */
public synchronized void pause() {
paused = true;
} /**
 * 终止进程,终止后无法再启动
 */
public void interrupt() {
runflag = false;
super.interrupt();
System.out.println("MyThread is interrupted!");
}}
线程是运行起来了,但是报错:
Exception in thread "Thread-7" java.lang.UnsatisfiedLinkError: hasMustSubmitOrPopups
at nari.pmds.simulator.Magicube.hasMustSubmitOrPopups(Native Method)
at nari.pmds.server.CheckWindowThread.run(CheckWindowThread.java:29)请教一下是不是多线程访问jni接口有什么问题啊?
注:我的主程序访问magicube里面的接口函数是没有问题的