<s>
In	O
computer	B-General_Concept
programming	I-General_Concept
,	O
a	O
thread	B-Operating_System
pool	I-Operating_System
is	O
a	O
software	O
design	O
pattern	O
for	O
achieving	O
concurrency	B-Architecture
of	O
execution	O
in	O
a	O
computer	O
program	O
.	O
</s>
<s>
Often	O
also	O
called	O
a	O
replicated	O
workers	O
or	O
worker-crew	O
model	O
,	O
a	O
thread	B-Operating_System
pool	I-Operating_System
maintains	O
multiple	O
threads	B-Operating_System
waiting	O
for	O
tasks	B-General_Concept
to	O
be	O
allocated	O
for	O
concurrent	B-Operating_System
execution	O
by	O
the	O
supervising	O
program	O
.	O
</s>
<s>
By	O
maintaining	O
a	O
pool	O
of	O
threads	B-Operating_System
,	O
the	O
model	O
increases	O
performance	B-Device
and	O
avoids	O
latency	O
in	O
execution	O
due	O
to	O
frequent	O
creation	O
and	O
destruction	O
of	O
threads	B-Operating_System
for	O
short-lived	O
tasks	B-General_Concept
.	O
</s>
<s>
The	O
number	O
of	O
available	O
threads	B-Operating_System
is	O
tuned	O
to	O
the	O
computing	O
resources	O
available	O
to	O
the	O
program	O
,	O
such	O
as	O
a	O
parallel	O
task	O
queue	O
after	O
completion	O
of	O
execution	O
.	O
</s>
<s>
The	O
size	O
of	O
a	O
thread	B-Operating_System
pool	I-Operating_System
is	O
the	O
number	O
of	O
threads	B-Operating_System
kept	O
in	O
reserve	O
for	O
executing	O
tasks	B-General_Concept
.	O
</s>
<s>
It	O
is	O
usually	O
a	O
tunable	O
parameter	O
of	O
the	O
application	O
,	O
adjusted	O
to	O
optimize	O
program	O
performance	B-Device
.	O
</s>
<s>
Deciding	O
the	O
optimal	O
thread	B-Operating_System
pool	I-Operating_System
size	O
is	O
crucial	O
to	O
optimize	O
performance	B-Device
.	O
</s>
<s>
One	O
benefit	O
of	O
a	O
thread	B-Operating_System
pool	I-Operating_System
over	O
creating	O
a	O
new	O
thread	B-Operating_System
for	O
each	O
task	O
is	O
that	O
thread	B-Operating_System
creation	O
and	O
destruction	O
overhead	O
is	O
restricted	O
to	O
the	O
initial	O
creation	O
of	O
the	O
pool	O
,	O
which	O
may	O
result	O
in	O
better	O
performance	B-Device
and	O
better	O
system	O
stability	B-Application
.	O
</s>
<s>
Creating	O
and	O
destroying	O
a	O
thread	B-Operating_System
and	O
its	O
associated	O
resources	O
can	O
be	O
an	O
expensive	O
process	O
in	O
terms	O
of	O
time	O
.	O
</s>
<s>
An	O
excessive	O
number	O
of	O
threads	B-Operating_System
in	O
reserve	O
,	O
however	O
,	O
wastes	O
memory	O
,	O
and	O
context-switching	O
between	O
the	O
runnable	O
threads	B-Operating_System
invokes	O
performance	B-Device
penalties	O
.	O
</s>
<s>
A	O
socket	O
connection	O
to	O
another	O
network	O
host	O
,	O
which	O
might	O
take	O
many	O
CPU	O
cycles	O
to	O
drop	O
and	O
re-establish	O
,	O
can	O
be	O
maintained	O
more	O
efficiently	O
by	O
associating	O
it	O
with	O
a	O
thread	B-Operating_System
that	O
lives	O
over	O
the	O
course	O
of	O
more	O
than	O
one	O
network	O
transaction	O
.	O
</s>
<s>
Using	O
a	O
thread	B-Operating_System
pool	I-Operating_System
may	O
be	O
useful	O
even	O
putting	O
aside	O
thread	B-Operating_System
startup	O
time	O
.	O
</s>
<s>
There	O
are	O
implementations	O
of	O
thread	B-Operating_System
pools	I-Operating_System
that	O
make	O
it	O
trivial	O
to	O
queue	O
up	O
work	O
,	O
control	O
concurrency	B-Architecture
and	O
sync	O
threads	B-Operating_System
at	O
a	O
higher	O
level	O
than	O
can	O
be	O
done	O
easily	O
when	O
manually	O
managing	O
threads	B-Operating_System
.	O
</s>
<s>
In	O
these	O
cases	O
the	O
performance	B-Device
benefits	O
of	O
use	O
may	O
be	O
secondary	O
.	O
</s>
<s>
Typically	O
,	O
a	O
thread	B-Operating_System
pool	I-Operating_System
executes	O
on	O
a	O
single	O
computer	O
.	O
</s>
<s>
However	O
,	O
thread	B-Operating_System
pools	I-Operating_System
are	O
conceptually	O
related	O
to	O
server	B-Operating_System
farms	I-Operating_System
in	O
which	O
a	O
master	O
process	O
,	O
which	O
might	O
be	O
a	O
thread	B-Operating_System
pool	I-Operating_System
itself	O
,	O
distributes	O
tasks	B-General_Concept
to	O
worker	O
processes	O
on	O
different	O
computers	O
,	O
in	O
order	O
to	O
increase	O
the	O
overall	O
throughput	O
.	O
</s>
<s>
Embarrassingly	B-Operating_System
parallel	I-Operating_System
problems	I-Operating_System
are	O
highly	O
amenable	O
to	O
this	O
approach	O
.	O
</s>
<s>
The	O
number	O
of	O
threads	B-Operating_System
may	O
be	O
dynamically	O
adjusted	O
during	O
the	O
lifetime	O
of	O
an	O
application	O
based	O
on	O
the	O
number	O
of	O
waiting	O
tasks	B-General_Concept
.	O
</s>
<s>
For	O
example	O
,	O
a	O
web	B-Application
server	I-Application
can	O
add	O
threads	B-Operating_System
if	O
numerous	O
web	O
page	O
requests	O
come	O
in	O
and	O
can	O
remove	O
threads	B-Operating_System
when	O
those	O
requests	O
taper	O
down	O
.	O
</s>
<s>
The	O
cost	O
of	O
having	O
a	O
larger	O
thread	B-Operating_System
pool	I-Operating_System
is	O
increased	O
resource	O
usage	O
.	O
</s>
<s>
The	O
algorithm	O
used	O
to	O
determine	O
when	O
to	O
create	O
or	O
destroy	O
threads	B-Operating_System
affects	O
the	O
overall	O
performance	B-Device
:	O
</s>
<s>
Creating	O
too	O
many	O
threads	B-Operating_System
wastes	O
resources	O
and	O
costs	O
time	O
creating	O
the	O
unused	O
threads	B-Operating_System
.	O
</s>
<s>
Destroying	O
too	O
many	O
threads	B-Operating_System
requires	O
more	O
time	O
later	O
when	O
creating	O
them	O
again	O
.	O
</s>
<s>
Creating	O
threads	B-Operating_System
too	O
slowly	O
might	O
result	O
in	O
poor	O
client	O
performance	B-Device
(	O
long	O
wait	O
times	O
)	O
.	O
</s>
<s>
Destroying	O
threads	B-Operating_System
too	O
slowly	O
may	O
starve	O
other	O
processes	O
of	O
resources	O
.	O
</s>
