What is a thread and how does it differ from a process?
Published on 2026-10-20 by frfrand
Threads and processes explained with examples: shared memory, concurrency, parallelism, locks, and when it is worth using each one.

Short answer: A thread is a unit of execution within a process. A single program can have multiple threads working concurrently and sharing an important part of their resources, such as process memory.
The difference with an independent process matters when designing servers, desktop applications, or tasks that need to do several things at once.
The restaurant example
Imagine a restaurant. A full kitchen can represent a process, while several people working inside that kitchen represent threads.
They share ingredients, tools, and space, which facilitates collaboration. But if two people modify the same order list at the same time without coordinating, they can produce errors.
A different process is more like another kitchen with its own resources, although both can communicate and share certain services.
How do processes and threads differ?
Processes usually have isolated memory spaces from each other, while threads of the same process share memory and other resources.
That shared memory allows exchanging information quickly, but it also introduces risks: two threads could modify the same value simultaneously and leave it in an unexpected state.
That is why concurrent programming uses mechanisms such as locks, semaphores, and communication queues.
Is concurrency the same as parallelism?
Not exactly. Concurrency means organizing several tasks so that they progress during a common period. Parallelism implies executing work simultaneously on different processing resources.
A person can cook two dishes by alternating steps: there is concurrency, but not two people cooking at the same time. With two cooks there could be parallelism.
The operating system, the programming language, and the hardware influence how threads actually execute.
What are threads for?
They can be useful in servers that handle multiple operations, programs with interfaces that must not remain blocked, and tasks that wait for network or disk responses.
For example, an application can keep its interface available while another part waits to download information. But this does not mean that any work is sped up by multiplying threads.
Tasks that consume CPU intensively may have different limits depending on the language and the runtime.
What about Python and the GIL?
In usual CPython implementations, there is a mechanism called Global Interpreter Lock (GIL) that affects the simultaneous execution of Python bytecode in traditional configurations.
That explains why creating many threads in Python usually does not speed up CPU-intensive calculations linearly. For certain jobs, multiple processes or specialized extensions are used.
The Python ecosystem is also evolving with no-GIL compilation options. That is why it is worth checking the version and configuration your application actually uses instead of repeating absolute rules.
What is a race condition?
It occurs when the result of a program depends on an execution order that is not properly controlled.
For example, two threads read that ten units of stock remain and both try to reserve the last one. If the logic is not synchronized or does not use correct transactions, an inconsistency can occur.
It is not necessarily solved by using fewer threads: access to shared resources must be designed well.
When is it worth using separate processes?
When you need stronger isolation, to take advantage of multiple cores in certain runtimes, or to run components with different responsibilities.
However, processes also require communication and can consume more resources. The decision depends on the task, the language, and the level of isolation needed.
Do more threads mean more performance?
Not always. Too many threads can increase context switches, memory usage, and coordination. If they all wait for the same database, creating one hundred threads will not eliminate the bottleneck.
It is worth measuring before increasing concurrency and setting appropriate limits for each workload.
And in ArduMaker?
Services deployed within an ArduMaker VPS can use processes, threads, or workers depending on how each application is developed. The infrastructure provides resources; choosing the correct concurrency model is part of backend design.
In summary: a process is an execution environment and a thread is a unit of work within it. They share advantages and risks that are worth understanding before attempting to speed up an application.
Sources: Python threading module · What is a kernel.

Processes and threads when sizing a VPS
An API can handle requests with different workers or threads depending on its application server. Increasing the number of threads does not ensure better performance: if the work is limited by CPU, memory, locks, or PostgreSQL connections, the improvement can be null or negative.
On an ArduMaker VPS, it is advisable to measure real concurrency before modifying parameters. For example, for Gunicorn, check how many workers the memory supports and observe if queries block for too long. If you need long-running jobs, separate them from the HTTP request using a queue. In ArduMaker's deploy configuration, the web and the worker can be separate processes of the same app, each with its own systemd service.
Frequently asked questions
What is a deadlock?
It is a mutual block: two threads (or processes) each wait for a resource that the other has, and neither advances. It is avoided, for example, by always taking locks in the same order or using wait times.
Is asynchronous programming the same as using threads?
No. With async/await, a single thread alternates between many tasks while they wait for network or disk, without creating a thread per task. It is very efficient for wait operations, but it does not take advantage of multiple cores for intensive calculations: for that, processes or threads are still needed.
Related: What is a worker · How to measure a server.