Does the current HotSpot JVM run in parallel by default?

感情迁移 提交于 2019-12-11 09:50:15

问题


I'm using this Java version:

java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.3) (suse-9.1-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

When I start a java program, e.g.

java TestApp

by default, will the JVM run in parallel ?

If so, which parts run in parallel ?

I am interested in this, because I found if I use taskset -c 0 java TestApp to bind TestApp running on processor 0, the first running time is much slower than java TestApp. Does this imply something?


回答1:


There are a number of single threaded tasks which have a thread of their own.

  • the main thread which runs you program
  • the background byte code to native compiler
  • the finalizer thread (to call finalize() on objects)
  • the GC thread pool

Your code will only use as many threads as you create (plus "main" which created for you)




回答2:


The JVM has native threads and no Global Lock, if that's what you're asking.




回答3:


The first running time is probably largely JITing the bytecode to machine code. I would suspect very strongly that process is optimized for parallel scenarios.



来源:https://stackoverflow.com/questions/12219424/does-the-current-hotspot-jvm-run-in-parallel-by-default

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!