An Analogy
Swaranga Sarma
sarma.swaranga at gmail.com
Tue Jul 19 19:22:26 UTC 2022
To take it a little bit further, you could also say there are physical
desks/counters where the tellers are supposed to work. And the number of
desks/counters is usually less than the number of tellers. Here the
desks/counters are the actual CPU cores. Since not all tellers will get a
desk at the same time, the manager (the OS) will sometimes ask a teller to
release a desk and allow another teller with some pending customers to
serve at the desk. This swap sometimes happens if a certain teller has
occupied a desk for a length of time and some other teller hasn't had a
chance to serve its pending customers. This is analogous to platform thread
scheduling by the OS on the actual cores.
Much simplified, but helped me create a mental model.
Regards
Swaranga
On Tue, Jul 19, 2022 at 12:13 PM Bazlur Rahman <anmbrr.bit0112 at gmail.com>
wrote:
> Hey Eric,
>
> A great analogy, I wonder if I can use it in my talk at the PhillyJUG (of
> course, using your reference) today.
>
> *Thank you,*
> *-*
> *A N M Bazlur Rahman*
>
>
>
>
> On Tue, Jul 19, 2022 at 2:34 PM <eric at kolotyluk.net> wrote:
>
>> 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…
>> 1. The teller sends a text message or emails to get the necessary
>> information
>> 2. 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
>> 3. The teller starts processing the next customer in line
>> 4. 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/87492830/attachment.htm>
More information about the loom-dev
mailing list