An Analogy

eric at kolotyluk.net eric at kolotyluk.net
Tue Jul 19 18:34:08 UTC 2022


I am hoping this is an apt analogy, so please correct me if it is wrong.

 

Before Loom, concurrency was like going to a bank with a fixed number of
tellers, where each teller had a line of customers.

 

1.	In Java terms, a teller is like Platform Thread
2.	Generally, it would take time to process each customer, say an
average of 5 minutes
3.	Sometimes, a customer would block the process, such as the teller
needed to make a phone call to get some information
4.	No work is performed, while the teller is blocked waiting, and
consequently the entire line is blocked

 

After Loom, concurrency is like going to a bank with more modern policies
and procedures

 

1.	In Java terms, a teller is still like a Platform Thread, but has the
ability to park a customer
2.	Generally, it still takes time to process each customer, say an
average of 5 minutes
3.	Sometimes, a customer would block the process, such as the teller
needed some information before proceeding.

a.	The teller sends a text message or emails to get the necessary
information
b.	The teller asks the customer to be seated, and as soon the
information is available, they will be the next customer processed by the
first available teller
c.	The teller starts processing the next customer in line
d.	This is analogous to a parked Virtual Thread, where the teller is
like a Platform Thread, and the customer is like a Virtual Thread

4.	Concurrency is increased, by better policies and procedures in
dealing with blocking operations

 

Yes, this is very simplistic, but intentionally so to try to expose what is
so great about Virtual Threads.

 

Cheers, Eric

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20220719/3cee6b23/attachment.htm>


More information about the loom-dev mailing list