Return to site

🧵 blocking vs non-blocking

In this talk, Bazlur Rahman gives intel on virtual threads that empower thread concurrency (you can run millions on thread now).

virtual threads diagram

broken image

banking teller analogy

  • A teller 👨 is like a platform thread 🧵 because they can only process one customer 👱 at a time.
  • A customer 👱 is like a task ✅ that the thread needs to perform.
  • Sometimes, a customer 👱 or a task may need some external information or resources 💾 before it can be completed. This is called a blocking operation 🛑 because it blocks the teller 👨 [or the platform thread 🧵] from doing anything else until it is resolved.
  • The teller 👨 [or the platform thread 🧵] can park the customer 👱 or the task that is blocked, and move on to the next one in line. This means that the customer 👱 or the task is temporarily suspended ⏸️, and will resume ▶️ when the blocking operation is resolved. This is called a parked virtual thread because it is a virtual thread that is parked by the platform thread 🧵.
  • By parking the customer 👱 or the task, the teller 👨 [or the platform thread 🧵] can process more customers or tasks at the same time, and increase the concurrency. Concurrency is the ability to run multiple tasks at the same time or in parallel.