Concurrency

concepts csharp

Concurrency is the general concept of having several things going on at the same time.

More formally, concurrency is when a program initiates a task before another one has completed so that different tasks are executed in overlapping time windows.

Types of Concurrency
  • Asynchrony: Your program performs non-blocking operations.

  • Parallelism: Your program leverages the hardware of multicore machines to execute tasks at the same time by breaking up work into tasks, each of which is executed on a separate core.

  • Multithreading: A software implementation that allows different threads to execute concurrently. A multithreaded program appears to be doing several things at the same time even when it’s running on a single-core machine.

Examples of Concurrency
  • Asynchrony: It’s a bit like when you send an email and then go on with your life without waiting for a response.

  • Parallelism: It’s a bit like singing in the shower: you’re actually doing two things at exactly the same time.

  • Multithreading: This is a bit like chatting with different people through various IM windows, although you’re actually switching back and forth. The net result is that you’re having multiple conversations at the same time