Home » Software Development » Native vs Green threads

About George Janeve

Native vs Green threads

Native vs Green threads 

Understanding a multi-threaded program have always been a wild goose chase for many programmers. There are always many aspects to consider when writing a multi-threaded program.

Green threads vs Native Threads

The difference between green threads vs native threads is something that programmers may be unaware of. Both are mechanisms are ways of achieving a ‘multi-threaded program’. It is the compiler / interpreter variants that usually implements green or native threads.

Native threads 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. Green threads are also known as ‘Cooperative Threading’ where each processes co-operate with each other to emulate a multi-threaded environment.

Execution in a multi-core machines

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.

Process Scheduling

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

Native threads usually have complicated synchronization and resource sharing. Multiple processes would require kernel level locks for synchronization. Synchronizations are pretty easier in case of green threads.

Reference: Native vs Green threads from our JCG partner George Janeve at the Janeve.Me blog.

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!

1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design

and many more ....

 

One comment

  1. Just few minor grammar or style mistakes:
    * “Both are mechanisms are ways of”
    * “singe”
    * “Native threads uses”
    * “Another advantage” – there is no previous advantage

Leave a Reply

Your email address will not be published. Required fields are marked *

*


Want to take your Java Skills to the next level?
Grab our programming books for FREE!
  • Save time by leveraging our field-tested solutions to common problems.
  • The books cover a wide range of topics, from JPA and JUnit, to JMeter and Android.
  • Each book comes as a standalone guide (with source code provided), so that you use it as reference.
Last Step ...

Where should we send the free eBooks?

Good Work!
To download the books, please verify your email address by following the instructions found on the email we just sent you.