使用多核处理器是否需要多线程算法? [英] Is Multi-Threaded algorithm required to make use of Multi-core processors?

查看:84
本文介绍了使用多核处理器是否需要多线程算法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道我们是否真的需要算法是多线程的,如果它必须使用多核处理器,或者即使我们的算法是顺序的,jvm也会使用多核处理器吗?

I was just wondering whether we actually need the algorithm to be muti-threaded if it must make use of the multi-core processors or will the jvm make use of multiple core's even-though our algorithm is sequential ?

更新:

相关问题:

推荐答案

我不相信任何当前的生产JVM实现都可以执行自动多线程.他们可能会使用其他内核进行垃圾回收和其他一些内部管理,但是如果您的代码是顺序表达的,则很难自动并行化它并仍然保留精确的语义.

I don't believe any current, production JVM implementations perform automatic multi-threading. They may use other cores for garbage collection and some other housekeeping, but if your code is expressed sequentially it's difficult to automatically parallelize it and still keep the precise semantics.

可能有 一些实验/研究JVM,它们试图并行化JIT令人尴尬地并行化的代码区域,但是我还没有听说过生产系统这样的东西.即使JIT did 发现了这种情况,它也可能比首先设计并行性代码的效率低. (按顺序编写代码,您可能很容易最终做出设计决定,从而无意间妨碍了自动并行性.)

There may be some experimental/research JVMs which try to parallelize areas of code which the JIT can spot as being embarrassingly parallel, but I haven't heard of anything like that for production systems. Even if the JIT did spot this sort of thing, it would probably be less effective than designing your code for parallelism in the first place. (Writing the code sequentially, you could easily end up making design decisions which would hamper automatic parallelism unintentionally.)

这篇关于使用多核处理器是否需要多线程算法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆