What is the difference between “green” threads and “native” threads?
Created: Sep 6, 2000 Author: Nathan Meyers (http://www.jguru.com/guru/viewbio.jsp?EID=138686) Both green and native threads are mechanisms to support multithreaded execution of Java programs. Some JDK distributions (such as Blackdown’s) include the option to run with either type of threading. Native threads use the operating system’s native ability to manage multi-threaded processes – in particular, they use the pthread library. When you run with native threads, the kernel schedules and manages the various threads that make up the process. Green threads emulate multithreaded environments without relying on any native OS capabilities. They run code in user space that manages and schedules threads; Sun wrote green threads to enable Java to work in environments that do not have native thread support. There are some important differences between using the two in a Linux environment: • Native threads can switch between threads pre-emptively, switching control from a running thread to a non-