💻
Software Engineering Notes
  • Introduction
  • Event-Sourcing
  • CQS and CQRS
  • Domain-Driven Design
    • Overview
    • Business Domain
    • Subdomain
    • Bounded Context
      • Interaction Between Contexts
    • Layers
      • Domain Layer
      • Application Layer
      • Infrastructure Layer
  • Database
    • In-Memory (Redis)
    • Search Engine (Elasticsearch)
    • Column-Oriented (Cassandra)
    • Document-Oriented (MongoDB)
  • Messaging
    • Brokers
      • Kafka
  • Race Condition
  • Concurrency vs Parallelism
  • API Architectural Styles
    • gRPC
  • Language & Framework Specific Notes
    • Go (Golang)
Powered by GitBook
On this page
  • Concurrency: dealing with multiple tasks at once
  • Parallelism: doing multiple tasks at once

Concurrency vs Parallelism

Concurrency: dealing with multiple tasks at once

Example: trying to eat while having a conversation.

  • It might be possible to do so, but you can't talk while chewing your food because you only have 1 mouth.

  • Your mouth switch context so often between chewing and talking, you might think that you are doing both in parallel at the same time (but actually, no).

  • In the context of software engineering, having 1 mouth in the example is the same as having only 1 thread.

  • Doing tasks asynchronously (with a single thread) will help us to achieve concurrency.

Parallelism: doing multiple tasks at once

Example: eating while having a conversation, but you have 2 mouths.

  • You have 2 mouths so you can eat and talk at the same time.

  • If eating while having a conversation will make the it finish at 10 minutes, having 2 mouths will help you to finish it in 5 minutes.

  • In the context of software engineering, having 2 mouths in the example is the same as having 2 threads with different cpu cores handling them.

PreviousRace ConditionNextAPI Architectural Styles

Last updated 1 year ago