36
There Is No Thread (blog.stephencleary.com)
you are viewing a single comment's thread
view the rest of the comments
[-] aloso@programming.dev 5 points 1 year ago

Even if this was true in 2013, when this article was written, the more accurate answer today would be "it depends".

In Rust, there are multi-threaded async executors implementing M:N threading (e.g. tokio), where M asynchronous tasks are mapped to N operating system threads. So when you await, the rest of the function may very well run in a different OS thread.

Swift also has async/await, and like tokio it uses multiple threads to run concurrent tasks in parallel (therefore using multiple OS threads).

Scala's equivalent to asynchronous tasks are Promises, which can also run in parallel, as I understand it.

Kotlin doesn't have async/await, but it has a similar concept, coroutines, which are basically a superset of asynchronous tasks. While Kotlin's coroutines are single-threaded by default, there is a multi-threaded implementation, enabling truly parallel coroutines.

Go also uses coroutines (which it calls "goroutines"), which can use multiple threads.

C++ will soon get coroutines as well, which support multithreading to run coroutines in parallel.

this post was submitted on 31 Jul 2023
36 points (90.9% liked)

Programming

17025 readers
52 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS