Search code examples
jvmjavajvm-hotspot

Does the current HotSpot JVM run in parallel by default?


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?


Solution

  • 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)