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.
And :
Does a new thread start when the program encounters a statement System.loadLibrary ?
Not unless the library creates one in its initialization section.
P.S. Does the behaviour change if you
join()the thread?