在Java中,可以在四核CPU上打开多少并发线程,有什么规则?

huangapple 未分类评论45阅读模式
英文:

How many concurrent threads can be opened on a quad core CPU in java, what is the rule?

问题

我正在开发一个独立的基于Java的应用程序,应该在至少四核机器上运行。该应用程序以PDF文件作为输入,并将其转换为Epub包作为输出。现在客户要求我使用多个核心来提高此应用程序的性能。我已经为每个要处理的PDF文件创建了一个线程,在四核机器上将同时打开四个线程池,从而将整个过程的性能提高了50%。

但是我对性能不满意,因为我认为性能至少可以提高80%,因为在单线程应用程序上,它每分钟可以生成10个文件,而现在在多线程应用程序上每分钟只能生成20个文件,而它应该每分钟生成40个文件,因为现在它在四个线程上同时运行。

请建议我应该采取什么方法来实现最佳结果,上述方法是否有什么问题?此外,我正在寻找建议,一个四核机器上可以同时打开多少个并发线程?

英文:

I am developing a standalone java based application which is supposed to be run on at least a quad core machine. This application takes PDF files as an input and creates an Epub package as an output, now client has asked me to increase the performance of this application using multiple cores. Now I have created one thread for each PDF file to be processed, and on a quad core machine pool of four threads will be opened at a time which increase the performance of whole process by 50%.

But i am not satisfied with the performance, as i think performance can be increase by 80% at least as on single thread application it was producing 10 files in a minutes, and now it is only producing 20 files in a minute on multithreded application where as it should have produced 40 files in a minute as now it is running in four threads at a time.

Kindly suggest what should I follow to achieve the optimal result, is there anything wrong in the above approach? Also i am looking for suggestions that how many concurrent threads can be opened on a quad core machine?

huangapple
  • 本文由 发表于 2020年5月19日 19:21:48
  • 转载请务必保留本文链接:https://java.coder-hub.com/61889817.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定