Thread
PronunciationTHRED
Definition
A thread is an independent path of execution inside a process. Threads of the same process share its memory, which makes them fast to communicate but easy to get wrong.
Where you hear it
In concurrency discussions, web server settings (worker threads), Python's GIL and performance tuning.
Examples
The server handles each request on a separate thread.
Access to the shared counter must be thread-safe.
Each worker thread pulls a job from the shared queue and processes it.
Common mistake
Sharing data between threads without protection. That causes data races and bugs that appear only sometimes.
Don't confuse with
A process, which has its own memory. Threads live inside a process and share its memory.
Say it at work
- In a meeting or chat
Is this code thread-safe?
- In an email or ticket
Use a thread pool instead of a thread per task.
Keep exploring
More in Programming Fundamentals