</>CodexBash
All articles
Programming

Threads explained

What a thread is and how to use threads safely: threads versus processes, creating threads in Java and Python, thread pools, shared memory and race conditions, locks, atomic variables and thread-safe collections, deadlocks, and Java's virtual threads.

CodexBash, , 6 min read

A thread is a single path of execution inside a program. Every program starts with one, the main thread, and can create more so that several pieces of work proceed at the same time: a server handling many requests, a game loading levels while you play, an app staying responsive while a file downloads. Threads are powerful because they share the program's memory, and dangerous for exactly the same reason. This article explains what threads are, how to create and manage them, and how to avoid the classic bugs.

Sign in to read the rest

The whole 6 minute article is free with an account, along with every problem, lesson and tutorial. No card.