Skip to content
StackDecode
System Design
16. Performance EngineeringAnimated

Concurrent Programming

Multiple tasks in progress at once.

The idea

Tasks interleave and may share state, which needs care.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

Txn 1Row ARow BTxn 2lock A
  • current message
  • earlier
  • failure or attack

Txn 1 locks row A.

step:
1/6
from:
Txn 1
to:
Row A
1/6

Time runs downward. Solid arrows are requests, dashed arrows are replies.

Step by step

  1. 1Split work into tasks
  2. 2Run them concurrently
  3. 3Protect shared state
  4. 4Join results

Where it is used

Servers.

Watch out for

Races and deadlocks.

Related