<s>
In	O
computer	B-General_Concept
programming	I-General_Concept
,	O
a	O
green	B-Operating_System
thread	I-Operating_System
(	O
virtual	B-Operating_System
thread	I-Operating_System
)	O
is	O
a	O
thread	B-Operating_System
that	O
is	O
scheduled	O
by	O
a	O
runtime	B-Library
library	I-Library
or	O
virtual	B-Architecture
machine	I-Architecture
(	O
VM	O
)	O
instead	O
of	O
natively	O
by	O
the	O
underlying	O
operating	B-General_Concept
system	I-General_Concept
(	O
OS	O
)	O
.	O
</s>
<s>
Green	B-Operating_System
threads	I-Operating_System
emulate	O
multithreaded	O
environments	O
without	O
relying	O
on	O
any	O
native	O
OS	O
abilities	O
,	O
and	O
they	O
are	O
managed	O
in	O
user	B-Operating_System
space	I-Operating_System
instead	O
of	O
kernel	B-Operating_System
space	I-Operating_System
,	O
enabling	O
them	O
to	O
work	O
in	O
environments	O
that	O
do	O
not	O
have	O
native	O
thread	B-Operating_System
support	O
.	O
</s>
<s>
Green	B-Operating_System
threads	I-Operating_System
refers	O
to	O
the	O
name	O
of	O
the	O
original	O
thread	B-Operating_System
library	B-Library
for	O
the	O
programming	O
language	O
Java	B-Language
(	O
that	O
was	O
released	O
in	O
version	O
1.1	O
and	O
then	O
Green	B-Operating_System
threads	I-Operating_System
were	O
abandoned	O
in	O
version	O
1.3	O
to	O
native	O
threads	B-Operating_System
)	O
.	O
</s>
<s>
Green	B-Operating_System
threads	I-Operating_System
share	O
a	O
single	O
operating	B-General_Concept
system	I-General_Concept
thread	B-Operating_System
through	O
co-operative	O
concurrency	O
and	O
can	O
therefore	O
not	O
achieve	O
parallelism	O
performance	O
gains	O
like	O
operating	B-General_Concept
system	I-General_Concept
threads	B-Operating_System
.	O
</s>
<s>
On	O
a	O
multi-core	B-Architecture
processor	I-Architecture
,	O
native	O
thread	B-Operating_System
implementations	O
can	O
automatically	O
assign	O
work	O
to	O
multiple	O
processors	O
,	O
whereas	O
green	B-Operating_System
thread	I-Operating_System
implementations	O
normally	O
cannot	O
.	O
</s>
<s>
Green	B-Operating_System
threads	I-Operating_System
can	O
be	O
started	O
much	O
faster	O
on	O
some	O
VMs	O
.	O
</s>
<s>
Benchmarks	O
on	O
computers	O
running	O
the	O
Linux	B-Operating_System
kernel	I-Operating_System
version	O
2.2	O
(	O
released	O
in	O
1999	O
)	O
have	O
shown	O
that	O
:	O
</s>
<s>
Green	B-Operating_System
threads	I-Operating_System
significantly	O
outperform	O
Linux	B-Operating_System
native	O
threads	B-Operating_System
on	O
thread	B-Operating_System
activation	O
and	O
synchronization	O
.	O
</s>
<s>
Linux	B-Operating_System
native	O
threads	B-Operating_System
have	O
slightly	O
better	O
performance	O
on	O
input/output	B-General_Concept
(	O
I/O	B-General_Concept
)	O
and	O
context	B-Operating_System
switching	I-Operating_System
operations	O
.	O
</s>
<s>
When	O
a	O
green	B-Operating_System
thread	I-Operating_System
executes	O
a	O
blocking	O
system	O
call	O
,	O
not	O
only	O
is	O
that	O
thread	B-Operating_System
blocked	O
,	O
but	O
all	O
of	O
the	O
threads	B-Operating_System
within	O
the	O
process	O
are	O
blocked	O
.	O
</s>
<s>
To	O
avoid	O
that	O
problem	O
,	O
green	B-Operating_System
threads	I-Operating_System
must	O
use	O
asynchronous	B-Architecture
I/O	I-Architecture
operations	O
,	O
although	O
the	O
increased	O
complexity	O
on	O
the	O
user	O
side	O
can	O
be	O
reduced	O
if	O
the	O
virtual	B-Architecture
machine	I-Architecture
implementing	O
the	O
green	B-Operating_System
threads	I-Operating_System
spawns	O
specific	O
I/O	B-General_Concept
processes	O
(	O
hidden	O
to	O
the	O
user	O
)	O
for	O
each	O
I/O	B-General_Concept
operation	I-General_Concept
.	O
</s>
<s>
There	O
are	O
also	O
mechanisms	O
which	O
allow	O
use	O
of	O
native	O
threads	B-Operating_System
and	O
reduce	O
the	O
overhead	O
of	O
thread	B-Operating_System
activation	O
and	O
synchronization	O
:	O
</s>
<s>
Thread	B-Operating_System
pools	I-Operating_System
reduce	O
the	O
cost	O
of	O
spawning	O
a	O
new	O
thread	B-Operating_System
by	O
reusing	O
a	O
limited	O
number	O
of	O
threads	B-Operating_System
.	O
</s>
<s>
Languages	O
which	O
use	O
virtual	B-Architecture
machines	I-Architecture
and	O
native	O
threads	B-Operating_System
can	O
use	O
escape	O
analysis	O
to	O
avoid	O
synchronizing	O
blocks	O
of	O
code	O
when	O
unneeded	O
.	O
</s>
<s>
In	O
Java	B-Language
1.1	O
,	O
green	B-Operating_System
threads	I-Operating_System
were	O
the	O
only	O
threading	O
model	O
used	O
by	O
the	O
Java	B-Language
virtual	I-Language
machine	I-Language
(	O
JVM	B-Language
)	O
,	O
at	O
least	O
on	O
Solaris	B-Application
.	O
</s>
<s>
As	O
green	B-Operating_System
threads	I-Operating_System
have	O
some	O
limitations	O
compared	O
to	O
native	O
threads	B-Operating_System
,	O
subsequent	O
Java	B-Language
versions	O
dropped	O
them	O
in	O
favor	O
of	O
native	O
threads	B-Operating_System
.	O
</s>
<s>
An	O
exception	O
to	O
this	O
is	O
the	O
Squawk	B-Language
virtual	I-Language
machine	I-Language
,	O
which	O
is	O
a	O
mixture	O
between	O
an	O
operating	B-General_Concept
system	I-General_Concept
for	O
low-power	O
devices	O
and	O
a	O
Java	B-Language
virtual	I-Language
machine	I-Language
.	O
</s>
<s>
It	O
uses	O
green	B-Operating_System
threads	I-Operating_System
to	O
minimize	O
the	O
use	O
of	O
native	B-Language
code	I-Language
,	O
and	O
to	O
support	O
migrating	O
its	O
isolates	O
.	O
</s>
<s>
are	O
open-source	O
projects	O
which	O
implement	O
green	B-Operating_System
threads	I-Operating_System
on	O
later	O
versions	O
of	O
the	O
JVM	B-Language
by	O
modifying	O
the	O
Java	B-Language
bytecode	I-Language
produced	O
by	O
the	O
Java	B-Language
compiler	O
(	O
Quasar	O
also	O
supports	O
Kotlin	B-Language
and	O
Clojure	B-Language
)	O
.	O
</s>
<s>
There	O
are	O
some	O
other	O
programming	O
languages	O
that	O
implement	O
equivalents	O
of	O
green	B-Operating_System
threads	I-Operating_System
instead	O
of	O
native	O
threads	B-Operating_System
.	O
</s>
<s>
Julia	B-Application
uses	O
green	B-Operating_System
threads	I-Operating_System
for	O
its	O
.	O
</s>
<s>
Lua	B-Language
uses	O
for	O
concurrency	O
.	O
</s>
<s>
Lua	B-Language
5.2	O
also	O
offers	O
true	O
C	O
coroutine	B-Architecture
semantics	O
through	O
the	O
functions	O
,	O
,	O
and	O
.	O
</s>
<s>
The	O
extension	O
allows	O
true	O
C	O
coroutine	B-Architecture
semantics	O
for	O
Lua	B-Language
5.1	I-Language
.	O
</s>
<s>
Rust	B-Application
runs	O
system	O
threads	B-Operating_System
natively	O
;	O
it	O
supports	O
green	B-Operating_System
threads	I-Operating_System
through	O
third-party	O
libraries	O
like	O
Tokio	B-Application
.	O
</s>
<s>
Smalltalk	B-Application
(	O
most	O
dialects	O
:	O
Squeak	B-Operating_System
,	O
VisualWorks	O
,	O
GNU	B-Application
Smalltalk	I-Application
,	O
etc	O
.	O
)	O
</s>
<s>
Stackless	B-Operating_System
Python	I-Operating_System
supports	O
either	O
preemptive	B-Operating_System
multitasking	I-Operating_System
or	O
cooperative	O
multitasking	O
through	O
microthreads	O
(	O
termed	O
tasklets	O
)	O
.	O
</s>
<s>
The	O
Erlang	B-Operating_System
virtual	B-Architecture
machine	I-Architecture
has	O
what	O
might	O
be	O
called	O
green	O
processes	O
–	O
they	O
are	O
like	O
operating	B-General_Concept
system	I-General_Concept
processes	O
(	O
they	O
do	O
not	O
share	O
state	O
like	O
threads	B-Operating_System
do	O
)	O
but	O
are	O
implemented	O
within	O
the	O
Erlang	B-Operating_System
Run	O
Time	O
System	O
(	O
erts	O
)	O
.	O
</s>
<s>
These	O
are	O
sometimes	O
termed	O
green	B-Operating_System
threads	I-Operating_System
,	O
but	O
have	O
significant	O
differences	O
from	O
standard	O
green	B-Operating_System
threads	I-Operating_System
.	O
</s>
<s>
In	O
the	O
case	O
of	O
GHC	O
Haskell	B-Language
,	O
a	O
context	B-Operating_System
switch	I-Operating_System
occurs	O
at	O
the	O
first	O
allocation	O
after	O
a	O
configurable	O
timeout	O
.	O
</s>
<s>
GHC	O
threads	B-Operating_System
are	O
also	O
potentially	O
run	O
on	O
one	O
or	O
more	O
OS	O
threads	B-Operating_System
during	O
their	O
lifetime	O
(	O
there	O
is	O
a	O
many-to-many	O
relationship	O
between	O
GHC	O
threads	B-Operating_System
and	O
OS	O
threads	B-Operating_System
)	O
,	O
allowing	O
for	O
parallelism	O
on	O
symmetric	B-Operating_System
multiprocessing	I-Operating_System
machines	O
,	O
while	O
not	O
creating	O
more	O
costly	O
OS	O
threads	B-Operating_System
than	O
needed	O
to	O
run	O
on	O
the	O
available	O
number	O
of	O
cores	O
.	O
</s>
<s>
occam	B-Language
is	O
unusual	O
in	O
this	O
list	O
because	O
its	O
original	O
implementation	O
was	O
made	O
for	O
the	O
Transputer	B-General_Concept
,	O
and	O
hence	O
no	O
virtual	B-Architecture
machine	I-Architecture
was	O
needed	O
.	O
</s>
<s>
Later	O
ports	O
to	O
other	O
processors	O
have	O
introduced	O
a	O
virtual	B-Architecture
machine	I-Architecture
modeled	O
on	O
the	O
design	O
of	O
the	O
Transputer	B-General_Concept
,	O
an	O
effective	O
choice	O
because	O
of	O
the	O
low	O
overheads	O
involved	O
.	O
</s>
<s>
Most	O
Smalltalk	B-Application
virtual	B-Architecture
machines	I-Architecture
do	O
not	O
count	O
evaluation	O
steps	O
;	O
however	O
,	O
the	O
VM	O
can	O
still	O
preempt	O
the	O
executing	O
thread	B-Operating_System
on	O
external	O
signals	O
(	O
such	O
as	O
expiring	O
timers	O
,	O
or	O
I/O	B-General_Concept
becoming	O
available	O
)	O
.	O
</s>
<s>
Usually	O
round-robin	B-Algorithm
scheduling	I-Algorithm
is	O
used	O
so	O
that	O
a	O
high-priority	O
process	O
that	O
wakes	O
up	O
regularly	O
will	O
effectively	O
implement	O
time-sharing	O
preemption	B-Operating_System
:	O
</s>
<s>
Other	O
implementations	O
,	O
e.g.	O
,	O
QKS	O
Smalltalk	B-Application
,	O
are	O
always	O
time-sharing	O
.	O
</s>
<s>
Unlike	O
most	O
green	B-Operating_System
thread	I-Operating_System
implementations	O
,	O
QKS	O
also	O
supports	O
preventing	O
priority	B-Operating_System
inversion	I-Operating_System
.	O
</s>
