Package biz.onixs.util.system
Class ThreadAffinity
- java.lang.Object
-
- biz.onixs.util.system.ThreadAffinity
-
public class ThreadAffinity extends Object
OS-depended thread wrapper implemented based on JNA.Please note that the library should be available in the classpath during runtime.
Currently it support Windows and Linux.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classThreadAffinity.cpu_set_tstatic classThreadAffinity.ErrorInfo
-
Field Summary
Fields Modifier and Type Field Description static intINVALID_CPU_INDEXstatic intTHREAD_AFFINITY_NOT_AVAILABLE
-
Constructor Summary
Constructors Constructor Description ThreadAffinity()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ThreadAffinity.ErrorInfogetLastError()static longsetAffinity(int[] cpuIndexes)Sets the thread affinity for the current thread.
-
-
-
Field Detail
-
THREAD_AFFINITY_NOT_AVAILABLE
public static final int THREAD_AFFINITY_NOT_AVAILABLE
- See Also:
- Constant Field Values
-
INVALID_CPU_INDEX
public static final int INVALID_CPU_INDEX
- See Also:
- Constant Field Values
-
-
Method Detail
-
setAffinity
public static long setAffinity(int[] cpuIndexes)
Sets the thread affinity for the current thread.- Parameters:
cpuIndexes- logical processors list that a thread is allowed to run on (first logical CPU has index 0).- Returns:
- On success, the affinity mask will be returned, otherwise 0.
-
getLastError
public static ThreadAffinity.ErrorInfo getLastError()
-
-