CPU中运行多个线程
我们都知道 JVM 在基于单个 CPU 的机器中调度用户线程。为什么单个 CP 不能并行运行多个进程/线程,什么限制阻止了该功能
而且 JVM 就像另一个软件,在任何机器上运行,可能有数千个其他程序可能在给定时间等待 CPU 周期,这之间 JVM 线程如何从 CPU 获取调度 给出周期分配速度/可能性的参数是什么任何机器上的任何进程。
All we know that JVM schedules the user threads in a single CPU based machine .Why cant a single CP run mltiple process/threads in parallel,What is the constrain stops that capability
Also JVM is like a another software which is running in any machine,There may be thousands of other programs may waiting for the CPU cycle at a given time between this how JVM threads get the schedules from the CPU What is the parameter which gives the speed/possibility of the allocation of cycles for any process in any machine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这实际上不是一个Java问题,而是一个cpu架构问题。
有些 CPU 确实每个核心并行运行多个线程。看看英特尔和超线程……一台带有 8 个线程的 4 核机器,其作用与您的建议相反。
This is not really a Java question, but a cpu architecture question.
And some CPUs DO run multiple threads in parallel per core. Look at Intel and Hyperthreading.. a 4 core machine with 8 threads, does the opposite of what you suggest.
传统的单核处理器一次只能处理一条指令,这意味着它们在任何一个时间点都只能在单个线程中工作。
多线程支持是通过让线程在 CPU 上“轮流”来综合实现的,以便它们看起来是同时运行的。
多核处理器可以在任意一个时间点处理每个 CPU 的一条指令。
这个问题更多地与CPU硬件设计有关,而不是与编程有关,尤其是与单一语言(即java)有关,因为限制是全面的。
traditional single-core processors can only process one instruction at a time, meaning that they can only work in a single thread at any one point in time.
multithread support is achieved synthetically by giving threads 'turns' on the cpu so that they appear to be running concurrently.
multi-core processors can process an instruction per CPU at any one point in time.
this question is more in relation to CPU hardware design than programming and especially not a single language ie java as the restriction is across the board.