Monday, 16 January 2017

Green Thread VS Native Thread

Green Thread VS Native Thread
Both are ways of achieving a ‘multi-threaded program’

     A native thread uses the operating systems threading capability to execute multi-threaded programs. On the other hand, the green threads emulates the multi-threading without using the underlying capabilities of the OS.

     Another advantage of native threads is that multiple processes would execute in parallel in a multi-core machine. On the other hand, green threads are executed on a single core the entire time and it is the VM that gives a multi-threading notion. So actually there is only singe executing in case of green threads.

     Native threads uses OS scheduling algorithm. Modern day OSes support pre-emptive scheduling. Green threads can use any kind of scheduling algorithm. Synchronization and Resource sharing

     Green threads are scheduled by a virtual machine; native threads are scheduled by an operational system.


     Green Threads were used earlier in Java1.3

No comments:

Post a Comment