i try to use this in win 10 with jdk 1.8、java-thread-affinity v3.2.3,the pc is 4 core with 8 thread.
code like this:
ExecutorService ES = Executors.newFixedThreadPool(4, new AffinityThreadFactory("bg", AffinityStrategies.ANY)); System.out.println("\nThe assignment of CPUs is\n" + AffinityLock.dumpLocks()); return ES;
and console log is :
The assignment of CPUs is
0: CPU not available
1: Reserved for this application
2: Reserved for this application
3: Reserved for this application
4: Reserved for this application
5: Reserved for this application
6: Reserved for this application
7: Reserved for this application
does this mean bind fail?
when run code to cal, got error:
09:17:28.174 [bg] INFO n.o.a.AffinityLock - [bind,314] - Assigning cpu 7 to Thread[bg,5,main] on thread id 9540
09:17:28.175 [bg-2] INFO n.o.a.AffinityLock - [bind,314] - Assigning cpu 6 to Thread[bg-2,5,main] on thread id 5904
09:17:28.176 [bg-4] INFO n.o.a.AffinityLock - [bind,314] - Assigning cpu 5 to Thread[bg-4,5,main] on thread id 22164
09:17:28.176 [bg-3] INFO n.o.a.AffinityLock - [bind,314] - Assigning cpu 4 to Thread[bg-3,5,main] on thread id 23148
Exception in thread "bg" Exception in thread "bg-2" java.lang.IllegalStateException: SetThreadAffinityMask((-2) , &({6}) ) errorNo=6
at net.openhft.affinity.impl.WindowsJNAAffinity.setAffinity(WindowsJNAAffinity.java:104)
at net.openhft.affinity.Affinity.setAffinity(Affinity.java:159)
at net.openhft.affinity.AffinityLock.bind(AffinityLock.java:319)
at net.openhft.affinity.AffinityLock.assignCurrentThread(AffinityLock.java:287)
at net.openhft.affinity.LockInventory.updateLockForCurrentThread(LockInventory.java:73)
at net.openhft.affinity.LockInventory.acquireLock(LockInventory.java:123)
at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:256)
at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:163)
at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:141)
at net.openhft.affinity.AffinityThreadFactory.acquireLockBasedOnLast(AffinityThreadFactory.java:69)
at net.openhft.affinity.AffinityThreadFactory.access$000(AffinityThreadFactory.java:32)
at net.openhft.affinity.AffinityThreadFactory$1.run(AffinityThreadFactory.java:59)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.sun.jna.LastErrorException: [6] 句柄无效。
at com.sun.jna.Native.invokeVoid(Native Method)
at com.sun.jna.Function.invoke(Function.java:415)
at com.sun.jna.Function.invoke(Function.java:361)
at com.sun.jna.Library$Handler.invoke(Library.java:265)
at net.openhft.affinity.impl.$Proxy277.SetThreadAffinityMask(Unknown Source)
at net.openhft.affinity.impl.WindowsJNAAffinity.setAffinity(WindowsJNAAffinity.java:102)
... 12 more
Exception in thread "bg-4" java.lang.IllegalStateException: SetThreadAffinityMask((-2) , &({5}) ) errorNo=6
at net.openhft.affinity.impl.WindowsJNAAffinity.setAffinity(WindowsJNAAffinity.java:104)
at net.openhft.affinity.Affinity.setAffinity(Affinity.java:159)
at net.openhft.affinity.AffinityLock.bind(AffinityLock.java:319)
at net.openhft.affinity.AffinityLock.assignCurrentThread(AffinityLock.java:287)
at net.openhft.affinity.LockInventory.updateLockForCurrentThread(LockInventory.java:73)
at net.openhft.affinity.LockInventory.acquireLock(LockInventory.java:123)
at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:256)
at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:163)
at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:141)
at net.openhft.affinity.AffinityThreadFactory.acquireLockBasedOnLast(AffinityThreadFactory.java:69)
at net.openhft.affinity.AffinityThreadFactory.access$000(AffinityThreadFactory.java:32)
at net.openhft.affinity.AffinityThreadFactory$1.run(AffinityThreadFactory.java:59)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.sun.jna.LastErrorException: [6] 句柄无效。
at com.sun.jna.Native.invokeVoid(Native Method)
at com.sun.jna.Function.invoke(Function.java:415)
at com.sun.jna.Function.invoke(Function.java:361)
at com.sun.jna.Library$Handler.invoke(Library.java:265)
at net.openhft.affinity.impl.$Proxy277.SetThreadAffinityMask(Unknown Source)
at net.openhft.affinity.impl.WindowsJNAAffinity.setAffinity(WindowsJNAAffinity.java:102)
... 12 more
Exception in thread "bg-3" java.lang.IllegalStateException: SetThreadAffinityMask((-2) , &({4}) ) errorNo=6
at net.openhft.affinity.impl.WindowsJNAAffinity.setAffinity(WindowsJNAAffinity.java:104)
at net.openhft.affinity.Affinity.setAffinity(Affinity.java:159)
at net.openhft.affinity.AffinityLock.bind(AffinityLock.java:319)
at net.openhft.affinity.AffinityLock.assignCurrentThread(AffinityLock.java:287)
at net.openhft.affinity.LockInventory.updateLockForCurrentThread(LockInventory.java:73)
at net.openhft.affinity.LockInventory.acquireLock(LockInventory.java:123)
at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:256)
at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:163)
at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:141)
at net.openhft.affinity.AffinityThreadFactory.acquireLockBasedOnLast(AffinityThreadFactory.java:69)
at net.openhft.affinity.AffinityThreadFactory.access$000(AffinityThreadFactory.java:32)
at net.openhft.affinity.AffinityThreadFactory$1.run(AffinityThreadFactory.java:59)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.sun.jna.LastErrorException: [6] 句柄无效。
at com.sun.jna.Native.invokeVoid(Native Method)
at com.sun.jna.Function.invoke(Function.java:415)
at com.sun.jna.Function.invoke(Function.java:361)
at com.sun.jna.Library$Handler.invoke(Library.java:265)
at net.openhft.affinity.impl.$Proxy277.SetThreadAffinityMask(Unknown Source)
at net.openhft.affinity.impl.WindowsJNAAffinity.setAffinity(WindowsJNAAffinity.java:102)
... 12 more
java.lang.IllegalStateException: SetThreadAffinityMask((-2) , &({7}) ) errorNo=6
at net.openhft.affinity.impl.WindowsJNAAffinity.setAffinity(WindowsJNAAffinity.java:104)
at net.openhft.affinity.Affinity.setAffinity(Affinity.java:159)
at net.openhft.affinity.AffinityLock.bind(AffinityLock.java:319)
at net.openhft.affinity.AffinityLock.assignCurrentThread(AffinityLock.java:287)
at net.openhft.affinity.LockInventory.updateLockForCurrentThread(LockInventory.java:73)
at net.openhft.affinity.LockInventory.acquireLock(LockInventory.java:123)
at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:256)
at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:163)
at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:141)
at net.openhft.affinity.AffinityThreadFactory.acquireLockBasedOnLast(AffinityThreadFactory.java:69)
at net.openhft.affinity.AffinityThreadFactory.access$000(AffinityThreadFactory.java:32)
at net.openhft.affinity.AffinityThreadFactory$1.run(AffinityThreadFactory.java:59)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.sun.jna.LastErrorException: [6] 句柄无效。
at com.sun.jna.Native.invokeVoid(Native Method)
at com.sun.jna.Function.invoke(Function.java:415)
at com.sun.jna.Function.invoke(Function.java:361)
at com.sun.jna.Library$Handler.invoke(Library.java:265)
at net.openhft.affinity.impl.$Proxy277.SetThreadAffinityMask(Unknown Source)
at net.openhft.affinity.impl.WindowsJNAAffinity.setAffinity(WindowsJNAAffinity.java:102)
... 12 more
This problem has been solved, because JNA is used in other places in my project, but the version is not 4.4.0, and the version conflicts. Just change the whole project to 4.4.0.
i try to use this in win 10 with jdk 1.8、java-thread-affinity v3.2.3,the pc is 4 core with 8 thread. code like this:
ExecutorService ES = Executors.newFixedThreadPool(4, new AffinityThreadFactory("bg", AffinityStrategies.ANY)); System.out.println("\nThe assignment of CPUs is\n" + AffinityLock.dumpLocks()); return ES;
and console log is : The assignment of CPUs is 0: CPU not available 1: Reserved for this application 2: Reserved for this application 3: Reserved for this application 4: Reserved for this application 5: Reserved for this application 6: Reserved for this application 7: Reserved for this application
does this mean bind fail?
when run code to cal, got error: 09:17:28.174 [bg] INFO n.o.a.AffinityLock - [bind,314] - Assigning cpu 7 to Thread[bg,5,main] on thread id 9540 09:17:28.175 [bg-2] INFO n.o.a.AffinityLock - [bind,314] - Assigning cpu 6 to Thread[bg-2,5,main] on thread id 5904 09:17:28.176 [bg-4] INFO n.o.a.AffinityLock - [bind,314] - Assigning cpu 5 to Thread[bg-4,5,main] on thread id 22164 09:17:28.176 [bg-3] INFO n.o.a.AffinityLock - [bind,314] - Assigning cpu 4 to Thread[bg-3,5,main] on thread id 23148 Exception in thread "bg" Exception in thread "bg-2" java.lang.IllegalStateException: SetThreadAffinityMask((-2) , &({6}) ) errorNo=6 at net.openhft.affinity.impl.WindowsJNAAffinity.setAffinity(WindowsJNAAffinity.java:104) at net.openhft.affinity.Affinity.setAffinity(Affinity.java:159) at net.openhft.affinity.AffinityLock.bind(AffinityLock.java:319) at net.openhft.affinity.AffinityLock.assignCurrentThread(AffinityLock.java:287) at net.openhft.affinity.LockInventory.updateLockForCurrentThread(LockInventory.java:73) at net.openhft.affinity.LockInventory.acquireLock(LockInventory.java:123) at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:256) at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:163) at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:141) at net.openhft.affinity.AffinityThreadFactory.acquireLockBasedOnLast(AffinityThreadFactory.java:69) at net.openhft.affinity.AffinityThreadFactory.access$000(AffinityThreadFactory.java:32) at net.openhft.affinity.AffinityThreadFactory$1.run(AffinityThreadFactory.java:59) at java.lang.Thread.run(Thread.java:748) Caused by: com.sun.jna.LastErrorException: [6] 句柄无效。 at com.sun.jna.Native.invokeVoid(Native Method) at com.sun.jna.Function.invoke(Function.java:415) at com.sun.jna.Function.invoke(Function.java:361) at com.sun.jna.Library$Handler.invoke(Library.java:265) at net.openhft.affinity.impl.$Proxy277.SetThreadAffinityMask(Unknown Source) at net.openhft.affinity.impl.WindowsJNAAffinity.setAffinity(WindowsJNAAffinity.java:102) ... 12 more Exception in thread "bg-4" java.lang.IllegalStateException: SetThreadAffinityMask((-2) , &({5}) ) errorNo=6 at net.openhft.affinity.impl.WindowsJNAAffinity.setAffinity(WindowsJNAAffinity.java:104) at net.openhft.affinity.Affinity.setAffinity(Affinity.java:159) at net.openhft.affinity.AffinityLock.bind(AffinityLock.java:319) at net.openhft.affinity.AffinityLock.assignCurrentThread(AffinityLock.java:287) at net.openhft.affinity.LockInventory.updateLockForCurrentThread(LockInventory.java:73) at net.openhft.affinity.LockInventory.acquireLock(LockInventory.java:123) at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:256) at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:163) at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:141) at net.openhft.affinity.AffinityThreadFactory.acquireLockBasedOnLast(AffinityThreadFactory.java:69) at net.openhft.affinity.AffinityThreadFactory.access$000(AffinityThreadFactory.java:32) at net.openhft.affinity.AffinityThreadFactory$1.run(AffinityThreadFactory.java:59) at java.lang.Thread.run(Thread.java:748) Caused by: com.sun.jna.LastErrorException: [6] 句柄无效。 at com.sun.jna.Native.invokeVoid(Native Method) at com.sun.jna.Function.invoke(Function.java:415) at com.sun.jna.Function.invoke(Function.java:361) at com.sun.jna.Library$Handler.invoke(Library.java:265) at net.openhft.affinity.impl.$Proxy277.SetThreadAffinityMask(Unknown Source) at net.openhft.affinity.impl.WindowsJNAAffinity.setAffinity(WindowsJNAAffinity.java:102) ... 12 more Exception in thread "bg-3" java.lang.IllegalStateException: SetThreadAffinityMask((-2) , &({4}) ) errorNo=6 at net.openhft.affinity.impl.WindowsJNAAffinity.setAffinity(WindowsJNAAffinity.java:104) at net.openhft.affinity.Affinity.setAffinity(Affinity.java:159) at net.openhft.affinity.AffinityLock.bind(AffinityLock.java:319) at net.openhft.affinity.AffinityLock.assignCurrentThread(AffinityLock.java:287) at net.openhft.affinity.LockInventory.updateLockForCurrentThread(LockInventory.java:73) at net.openhft.affinity.LockInventory.acquireLock(LockInventory.java:123) at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:256) at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:163) at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:141) at net.openhft.affinity.AffinityThreadFactory.acquireLockBasedOnLast(AffinityThreadFactory.java:69) at net.openhft.affinity.AffinityThreadFactory.access$000(AffinityThreadFactory.java:32) at net.openhft.affinity.AffinityThreadFactory$1.run(AffinityThreadFactory.java:59) at java.lang.Thread.run(Thread.java:748) Caused by: com.sun.jna.LastErrorException: [6] 句柄无效。 at com.sun.jna.Native.invokeVoid(Native Method) at com.sun.jna.Function.invoke(Function.java:415) at com.sun.jna.Function.invoke(Function.java:361) at com.sun.jna.Library$Handler.invoke(Library.java:265) at net.openhft.affinity.impl.$Proxy277.SetThreadAffinityMask(Unknown Source) at net.openhft.affinity.impl.WindowsJNAAffinity.setAffinity(WindowsJNAAffinity.java:102) ... 12 more java.lang.IllegalStateException: SetThreadAffinityMask((-2) , &({7}) ) errorNo=6 at net.openhft.affinity.impl.WindowsJNAAffinity.setAffinity(WindowsJNAAffinity.java:104) at net.openhft.affinity.Affinity.setAffinity(Affinity.java:159) at net.openhft.affinity.AffinityLock.bind(AffinityLock.java:319) at net.openhft.affinity.AffinityLock.assignCurrentThread(AffinityLock.java:287) at net.openhft.affinity.LockInventory.updateLockForCurrentThread(LockInventory.java:73) at net.openhft.affinity.LockInventory.acquireLock(LockInventory.java:123) at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:256) at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:163) at net.openhft.affinity.AffinityLock.acquireLock(AffinityLock.java:141) at net.openhft.affinity.AffinityThreadFactory.acquireLockBasedOnLast(AffinityThreadFactory.java:69) at net.openhft.affinity.AffinityThreadFactory.access$000(AffinityThreadFactory.java:32) at net.openhft.affinity.AffinityThreadFactory$1.run(AffinityThreadFactory.java:59) at java.lang.Thread.run(Thread.java:748) Caused by: com.sun.jna.LastErrorException: [6] 句柄无效。 at com.sun.jna.Native.invokeVoid(Native Method) at com.sun.jna.Function.invoke(Function.java:415) at com.sun.jna.Function.invoke(Function.java:361) at com.sun.jna.Library$Handler.invoke(Library.java:265) at net.openhft.affinity.impl.$Proxy277.SetThreadAffinityMask(Unknown Source) at net.openhft.affinity.impl.WindowsJNAAffinity.setAffinity(WindowsJNAAffinity.java:102) ... 12 more