January 28, 2024
In this talk, Bazlur Rahman gives intel on virtual threads that empower thread concurrency (you can run millions on thread now).
virtual threads diagram
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.