Concurrency In Programing

Jamal
1 min readFeb 6, 2022

Concurrency is the concept of executing two or more tasks at the same time (in parallel)

Examples of Concurrency

The real world contains actors that execute independently of but communicate with, each other. In modeling the world, many parallel executions have to be composed and coordinated, and that’s where the study of concurrency comes in. Consider:

  • Railway Networks (note shared sections of track)
  • Gardening (people rake, sweep, mow, plant, etc.)
  • Machines in a factory

Hardware examples

  • A single processor can have multiple execution pipelines (but only one set of registers)
  • A processor can have multiple cores (multicore)
  • A computer can have multiple processors

Software examples

Multiprogramming, or running a lot of programs concurrently (the O.S. has to multiplex their execution on available processors). For example:

  • downloading a file
  • listening to streaming audio
  • having a clock running

Why Study Concurrency?

  • Real-world systems are naturally concurrent, and computer science is about modeling the real world.
  • Concurrency is useful in multicore, multiprocessor, and distributed computer systems.
  • Increased performance from true parallelism
  • Increased reliability (fault tolerance)
  • Specialized processors (graphics, communication, encryption …)
  • Some applications, like email, are inherently distributed
  • Concurrent programming often results in superior program structure: write code for the different tasks and let some separate engine schedule the tasks.

--

--