如何强制两个Java线程在同一处理器/核心上运行? [英] How to force two Java threads to run on same processor/core?

查看:128
本文介绍了如何强制两个Java线程在同一处理器/核心上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个不包含关键部分或类似同步替代方案的解决方案。我正在寻找类似于Windows的光纤(用户级线程)的东西。

I would like a solution that doesn't include critical sections or similar synchronization alternatives. I'm looking for something similar the equivalent of Fiber (user level threads) from Windows.

推荐答案

操作系统管理线程是什么在什么核心上处理。您需要将线程分配给操作系统中的单个核心。

The OS manages what threads are processed on what core. You will need to assign the threads to a single core in the OS.

例如。在Windows上,打开任务管理器,转到进程选项卡,然后右键单击java进程...然后将它们分配给特定的核心。

For instance. On windows, open task manager, go to the processes tab and right click on the java processes... then assign them to a specific core.

这是最好的你将会得到。

That is the best you are going to get.

这篇关于如何强制两个Java线程在同一处理器/核心上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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