How does Java handle multithreading?

后端 未结 4 607
误落风尘
误落风尘 2020-12-19 17:01

How does Java decide which core to assign a thread or a process? Is there any way to control that? to prevent two large threads from executing on the same core?

Basi

4条回答
  •  再見小時候
    2020-12-19 17:44

    This really depends on the implementation on the JVM, but in general, Java implementations rely on the underlying OS's threading functionality. To the best of my knowledge there are no public and standard extensions to set an affinity. There may be experimental JVMs that offer hooks, however.

    Furthermore, interfering with the JVM abstraction to mess directly with the underlying platform goes, to a degree (and IMHO), against the spirit of Java.

提交回复
热议问题