Profile PictureManoj Kumar
Open menu

Async Vs Threads: Which one is for you?

July 21, 2018

(Updated on July 14, 2023)

article cover

Recently, I got into a discussion over a coffee about distributed systems in Test Automation and then started to discuss parallelism, concurrency which lead down to the path of Threads, MultiThreaded solutions to Asynchronous and Synchronous ways of tests or calls in programming.

Let’s look at them in brief!

Concurrency Vs Parallelism:

Concurrency: Two or more tasks can start, run and complete in overlapping time periods.

Parallelism: Two or more tasks started and executed at the same time.

Synchronous: You wait for it to finish before moving on to another task

Asynchronous: You can move on to another task before it finishes.

Asynchrony:

  • Async functions must have the ability to “suspend” and “resume”
  • An “event loop” keeps track of all the asynchronous functions and their stages of completion and schedules their access to CPU
  • Ways to implement functions that can suspend/resume in Python:
  • Ways to implement functions that can suspend/resume in JavaScript:
  • 👍LIKE
    ❤️LOVE
    👏CLAP
    🎉PARTY

    More articles

    If you enjoyed this article, you'll find these insightful too!