Forcing multiple threads to use multiple CPUs when they are available

后端 未结 10 1155
后悔当初
后悔当初 2020-11-28 19:21

I\'m writing a Java program which uses a lot of CPU because of the nature of what it does. However, lots of it can run in parallel, and I have made my program multi-threade

10条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-28 19:42

    There is no way to set CPU affinity in Java. http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4234402

    If you have to do it, use JNI to create native threads and set their affinity.

提交回复
热议问题