Guru R Handa
Guru R Handa

Reputation: 145

How JVM use operating system when creation of thread?

Here i try to learn java thread clearlly.. On which process JVM create the thread. Suppose if i create a thread in java then how JVM create this thread? To whom it will send to exicute?.. Which one is the base process for this...

Upvotes: 3

Views: 288

Answers (3)

SLaks
SLaks

Reputation: 888185

Most JVMs use standard OS calls to create native threads (eg, the Win32 CreateThread API, or POSIX pthread_create), and pass a native function within the JVM which proceeds to execute the Java code in the thread.

Upvotes: 6

musiKk
musiKk

Reputation: 15189

Actually the Java Virtual Machine Specification does not specify how threads are to be handled by a JVM. There is only a high level description. The Sun JVM itself made a change in this regard: Up to Java 1.1 it used so called Green Threads that are managed by the JVM itself. Later it used native threads that the host operating system provides.

Upvotes: 2

NPE
NPE

Reputation: 500893

There is a separate JVM process for every running Java application. The threads that the application creates are created within that process.

Upvotes: 3

Related Questions