Professional Documents
Culture Documents
Threads in Programming PDF
Threads in Programming PDF
Threads in Programming
Parathan Thiyagalingam Follow
Jun 14 · 3 min read
Have you ever wondered how big applications or software are working?
Imagine while you are playing video games you may have seen some
occurrences where changes occur concurrently like meter
measurements or the moving objects in the display. These won’t happen
at the same time. Each action is executed under a Thread. But those
thread execution changes within milliseconds, to our naked eye we
can’t observer what’s happening
An application can have multiple processes, the process can have multiple
threads.
Multiple threads can exist within one process, executing concurrently and
sharing resources such as memory, while different processes do not share
these resources.
In particular, the threads of a process share its executable code and the
values of its dynamically allocated variables and non-thread-local global
variables at any given time.
Process
The process starts with a single thread [Primary Thread] and later
can create more Thread from any of its Threads.
Threads
The smallest unit of execution to which processor allocates time
a Stack
Set of registers
A unique id
However, a thread itself is not a program. It cannot run on its own but
runs within a program
When a new request comes it will create a new thread inside that process
and send a response to the request.
Threads VS Process
Threads are easier to create than processes since they don’t require a
separate address space.
If you want to know about context-switching refer this link to get to know
about it
Ready
Running
Sleeping
Waiting
Dead
Blocked
When I/O request interrupted the execution it will move to Blocked state
and when the request is done will move to Ready state.
Methods in the arrow indication are used in Java to change the state of a
thread.
WRIT T EN BY
Exploring Cost Programming Using Vapor and Fluent ASP.NET Core Custom
Optimisation on AWS FUNdamentals —Lists, to create a REST API Drop Down List
Aayush Kumar in FinOps Talks Loops, and User Input Radu Dan Dmitry Sikorsky
T heCyberBasics in Python In
Plain English