Concurrent Programming
What is Concurrent Programming?
Concurrent Programming: Concurrency is about dealing with many things at once — tasks can start, run, and complete in overlapping time periods, whether or not they execute in true parallel. The core challenge is safely coordinating access to shared state. Concurrent programming is about dealing with several tasks whose lifetimes overlap. They may run truly in parallel on different processor cores, or take turns on one. Either way, the program has to coordinate them.
Frequently asked questions about Concurrent Programming
How is Concurrent Programming used in practice?
The hard part is shared state. When two tasks read and change the same data at the same time, results depend on timing. These bugs, called race conditions, appear only under load and are notoriously hard to reproduce.
What should you keep in mind with Concurrent Programming?
Web applications deal with concurrency constantly, because many requests run at once against the same database. The usual tools are database transactions, row locks, atomic updates and unique constraints. A good habit is to ask for every write: what happens if two requests do this at the same moment? If the answer is unclear, protect it.
At a glance
| Category | Programming paradigms |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |