Only the main thread will wait for thread 'a' to complete its execution. and that is because you have invoked join from the main thread. Try having a print statement in your main method after you invoke join, it would execute after thread 'a' completes.
The way Java threads are mapped to OS threads is up to the JVM and its use of multiple processors on a machine. Different JVMs use different strategies:
Some JVMs use green threads, running all Java threads in one native OS thread (called n-to-one mapping). Sun's HotSpot JVMA website external to this site uses native threads, which may execute in parallel on a multi-CPU machine. On Solaris, Java threads are not bound permanently to the same native threads but are remapped by the scheduler (in an n-to-m mapping).
1-What is thread mapping?
2-What is native thread?What its difference with green thread?
As far as I know, it depends on the implementation of the JVM. Modern JVM’s do not use their own but instead rely on the underlying operating system. This provides better performance as well. How the JVM maps Java threads to OS threads varies a bit, but in general each java thread is mapped on 1 native thread in the OS.
Regarding green threads, early implementation of JVM were used them as the only threading model. But now green threads have been removed completely from java code and are no longer supported. Modern JVM’s are now use native threads instead of them.
No they are not. Certainly not in the Sun VM. And I would doubt that for any recent VM on a desktop OS.
The OS does it.
Sure? Until I know (I'm not an expert at all) the jvm is scheduled by the OS, but the java threads are scheduled by the jvm. This way if you are running on a machine a jvm with 5 java threads and the mysql daemon, for example, OS will schedule the jvm as one process and the mysql daemon as another process. In the cpu time assigned by the OS to the jvm, it will schedule between the 5 java threads.
At best the VM will set the priority. Scheduling is by the OS.
Now,Who schedule threads? JVM or OS? what is the relationship between these of Thread scheduling?
Is it true that:
if one OS thread is mapped to two or more java thread then obviously it is the responsibility of JVM to decide which thread to run when the OS thread is running
if there is direct mapping like one OS thread == one Java thread, then ofcourse OS scheduler decides which thread to run
You didn't tell me he was so big. Unlike this tiny ad: