package keylogger;
public class TestKeys {
private static int i = 0;
private native void setWinHook();
private native void unregisterWinHook();
public static void main(String args[]) {
TestKeys o = new TestKeys();
System.loadLibrary("MyHook"); // load the library that registers the hook
Runnable r = new Runnable() {
@Override
public void run() {
System.out.println("After the call to System.loadLibrary");
}
};
new Thread(r,"new thread").start();
}
}
When i start the program,dll
is loaded and does it's work. But the statement inside the run method
of new thread
doesn't get printed. Why is that ? Why doesn't the java thread start ? The dll code doesn't return immediately. Infact there is no way it can return.
当我启动程序时,dll被加载并且它正常工作。但是新线程的run方法中的语句没有打印出来。这是为什么 ?为什么java线程没有启动? DLL代码不会立即返回。事实上,它无法返回。
And :
Does a new thread start when the program encounters a statement System.loadLibrary
?
当程序遇到语句System.loadLibrary时,新线程是否启动?
1 个解决方案
#1
2
Does a new thread start when the program encounters a statement System.loadLibrary ?
当程序遇到语句System.loadLibrary时,新线程是否启动?
Not unless the library creates one in its initialization section.
除非库在其初始化部分中创建一个,否则不会。
P.S. Does the behaviour change if you join()
the thread?
附:如果你加入()线程,行为会改变吗?
#1
2
Does a new thread start when the program encounters a statement System.loadLibrary ?
当程序遇到语句System.loadLibrary时,新线程是否启动?
Not unless the library creates one in its initialization section.
除非库在其初始化部分中创建一个,否则不会。
P.S. Does the behaviour change if you join()
the thread?
附:如果你加入()线程,行为会改变吗?