Matt Powell wrote:

> "Over here, we have a man. The man is ostensibly sitting on the couch
> watching rugby and drinking beer, but notice that he can't do both at the
> same time. When he's drinking his beer, he will often miss an important
> tackle or a particularly brilliant pass, and when the rugby gets really
> exciting, his beer will remain untouched for seconds at a time. The man is a
> SINGLE-TASKING PROCESS.
>
> "Over *here*, we have a woman. Notice how the woman is able to do more than
> one thing at once. For example, she can be doing the ironing, planning a
> complex meal and sorting out the social lives of her three children, all at
> the same time. The woman is a MULTI-TASKING PROCESS.

Actually I think the man is multi-tasking, and the woman is multi-processing.

SHE is doing TWO THINGS AT THE SAME TIME. For the sake of the analogy you could
think of it as her left brain performing one task and her right brain doing
another task. So she has two processors.

HE is repeatedly doing a number of tasks, but he is only ever performing ONE
TASK AT A TIME. His brain only ever performs one task at a time, but he divides
his time between tasks. So he has one processor that performs a number of tasks
in rapid succession. If the alternation between tasks is fast enough it looks
like he is doing two things at the same time.

I like the analogy though. It might get a laugh. Unfortunately it does not help
to explain problems with resources that are shared by different threads.

Kevin Wells

P.S. There was a series of articles about multi-threading by Alan Holub in
JavaWorld September 1999 (http://www.javaworld.com). He had a nice analogy for
mutexes:

"The best analogy I've heard for a monitor is an airplane bathroom. Only one
person can be in the bathroom at a time (we hope). Everybody else is queued up
in a rather narrow aisle waiting to use it. As long as the door is locked, the
bathroom is inaccessible. Given these terms, in our analogy the object is the
airplane, the bathroom is the monitor (assuming there's only one bathroom), and
the lock on the door is the mutex."

This leads to amusing examples of what happens if shared resources are not
protected correctly.

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to