Home

singlethreaded

Single-threaded refers to a program that executes all tasks on a single thread of execution, meaning there is one call stack, one program counter, and operations are performed one after another. There is no concurrent execution of code within the same process; context switches between threads do not occur because there is only one thread. Memory access is inherently sequential, reducing the complexity associated with data races and synchronization.

Most modern systems are multi-threaded by default, but single-threaded programs may still rely on asynchronous I/O

Common environments include JavaScript in web browsers, which follows a single-threaded event loop for executing scripts,

Advantages and drawbacks: Simplicity and predictability; no data races; easier debugging. Drawbacks include limited CPU parallelism,

See also: concurrency, multi-threading, event-driven programming, asynchronous I/O.

or
cooperative
multitasking
to
overlap
work
without
parallel
threads.
In
such
models,
the
program
can
initiate
an
I/O
operation
and
continue
processing
other
events,
while
the
I/O
completes
and
its
callback
is
scheduled
by
an
event
loop.
with
web
workers
available
for
parallel
tasks.
Node.js
uses
a
single-threaded
event
loop
for
JavaScript
code,
with
asynchronous
I/O
and
a
thread
pool
for
certain
operations.
Some
embedded
systems
and
early
GUI
frameworks
also
use
single-threaded
models.
potential
UI
freezing
if
operations
are
long-running,
and
reliance
on
asynchronous
patterns
to
maintain
responsiveness.