私はScientific Linuxボックスのリアルタイムプロパティに設定するJavaスレッドの優先順位を変更しようとしている小さなテストを作成しようとしています。JavaのJNI呼び出しを使用してスレッドの優先順位を変更する
これは、JNI呼び出しを使用して行う必要があり、Thread.MAX_PRIORITYまたはThread.MIN_PRIORITYを使用すると、リアルタイム優先順位にマップされません。
私のネイティブコードからJavaスレッドにアクセスするにはどうすればいいですか?
public class ThreadPriorityTest implements Runnable {
public static int numThreads;
public void run() {
System.out.println("***Java: Changing thread priorities");
changePriority();
}
public static synchronized native void changePriority();
public static void main(String[] args) {
if(args.length != 1) {
System.out.println("Usage: ThreadPriorityTest <num_of_threads>");
System.exit(0);
}
numThreads = Integer.parseInt(args[0]);
for(int i = 0; i < numThreads; i++) {
Thread t = new Thread(new ThreadPriorityTest());
t.start();
}
}
}