views:

103

answers:

2

In Java, is there a way to force a JVM instance to run on a single CPU/Core.

Additionally is there a way for given thread to figure out what CPU it is running on?

+3  A: 

This is not to be controlled at JVM/Java level, but at OS/platform level. In Windows for example, you can go to the Processes tab in the Task Manager and set the Affinity for most of the processes by choosing the appropriate option in the rightclick menu. With this you basically controls which CPU's/cores the process is allowed to use.

BalusC
+2  A: 

In Java, is there a way to force a JVM instance to run on a single CPU/Core.

No.

Additionally is there a way for given thread to figure out what CPU it is running on?

No.

Those answers should be qualified by saying that is is not possible to do these things in pure Java. You might be able to use JNI to call some OS specific native APIs to do these things. But it is simpler and cleaner to do the task from the command prompt or from some appropriate OS management GUI.

Stephen C