Sobes.tech
Junior — Middle

How many threads are created when launching a JVM application?

sobes.tech AI

Answer from AI

When a JVM application starts, several threads are created by default, among which the main ones are:

  • main — the main thread where the main method of your application runs.
  • GC (Garbage Collector) threads — responsible for garbage collection.
  • Finalizer Thread — a thread for executing finalize methods.
  • Reference Handler Thread — handles weak, soft, and phantom references.
  • Signal Dispatcher — handles OS signals.

The exact number of threads depends on the JVM implementation and configuration, but usually, there are about 5 to 10 threads immediately after startup. Additional threads are created as needed, for example, for thread pools, asynchronous tasks, etc.