What is Green Thread?

Technology CommunityCategory: ConcurrencyWhat is Green Thread?
VietMX Staff asked 3 years ago

Green Thread is a thread that is scheduled by a virtual machine (VM) instead of natively by the underlying operating system. Green threads emulate multithreaded environments without relying on any native OS capabilities, and they are managed in user space instead of kernel space, enabling them to work in environments that do not have native thread support.

Green Thread usually used when the OS does not provide a thread API, or it doesn’t work the way you need. Thus, the advantage is that you get thread-like functionality at all. The disadvantage is that green threads can’t actually use multiple cores. In the context of Java specifically, there were a few early JVMs that used green threads (IIRC the Blackdown JVM port to Linux did), but nowadays all mainstream JVMs use real threads. There may be some embedded JVMs that still use green threads.