在 Java 中实现多核 - 如何实现?
Java中实现多核最简单的方法是什么?我的意思是,具体指出执行项目某些部分的核心,因此旧的“普通”java 线程不是一个选择。
到目前为止,有人建议我使用 JConqurr(这是一个用于 java 多核编程的 Eclipse 工具包)、JaMP(为 OpenMP 扩展 Java)和 MPJ Express,我对其中了解不多。您认为以上哪一个最好,或者您还有其他建议吗?最好以某种方式测量性能提升/增益,但不是唯一的。
任何帮助将不胜感激。 谢谢, 二十九。
What is the easiest way in Java for achieving multi-core? And by this, I mean, to specifically point out on what core to execute some parts of the project, so good-old "normal" java threads are not an option.
So far, I was suggested JConqurr (which is an Eclipse toolkit for multi-core programming in java), JaMP (which extends Java for OpenMP), and MPJ express, of which I don't know much. Which of the above do you consider the best, or do you have other suggestions? It would be preferable to somehow mesure the performance boost/gain, but not exclusive.
Any help would be much appreciated.
Thanks,
twentynine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尽管用 Java 编写多线程代码很容易,但 Java 标准运行时中通常没有任何东西可以让您告诉 JVM 或操作系统如何调度您的程序。
因此,您将需要专门针对您的 JVM 和/或操作系统的代码,并且该代码可能无法在 Java 中执行(除非您深入研究 JNI 或 JNA)。在许多 Unix 版本(也可能是 Windows)中,外部程序可以将进程固定到 CPU,但我认为您不能对单个线程执行此操作。
Even though it is easy to write multi-threaded code in Java, there is nothing in the Java standard runtime which generically allow you to tell the JVM or the operating system how to schedule your program.
Hence you will need to have code specifically for your JVM and/or your operating system, and that code may not be doable in Java (unless you dive into JNI or JNA). External programs can pin processes to a CPU in many Unix versions (and probably Windows too), but I don't think you can do this for individual threads.
Scala 在这方面非常受欢迎。它在 JVM 上运行,并具有 Java 绑定以将它们连接在一起。
Scala is quite popular for this. It runs on the JVM and has bindings for Java to hook them together.