[Zope] Storing an object in RAM during Zope's up-time

Hung Jung Lu hungjunglu@hotmail.com
Sat, 08 Apr 2000 16:16:11 PDT


>From: Michel Pelletier <michel@digicool.com>
>Hung Jung Lu wrote:
> > but I seem to recall that Python is borrowing Java's
> > thread model... which almost makes me want to scream.
>
>I don't think this is true, there are actually two thread extensions for
>python, one is low-level and one is high-level.  It might be true that
>the high-level on is Java-esque, but the low-level one is very
>straightforward.

That's nice, yes, I was just looking into the two modules.
But I'd like to know more, so I just send a message to
Dag Gruneau (the person that implemented the NT thread
part), too.

>I believe almost all of the basic type operations in Python are thread
>safe, such as list.append(), if this is what you mean by 'exclusive
>time-slice', I'm not very up on the lingo.

Well, in Java, you can have the two lines:

    i = 3;
    System.out.println(i);

and it would print out 4 instead of 3, because between
the first line and the second line some other thread
has sneaked in and modified the value of i.

That's the scary part. You have no exclusive time-slice
(or in other words, the above two statements is non-blocking
as a whole.) That is, the above two lines of code don't
own the CPU time exclusively: some other thread may
sneak in. (You draw a chart of owner-thread of CPU time,
and different threads get slices of the CPU time. Say,
thread 1 uses CPU from 2000/03/21 03:32:54.323 to
2000/03/21 03:32:54.345, that's one slice. And thread 2
uses CPU from 2000/03/21 03:32:55.345 to
2000/03/21 03:32:54.367, that's another slice.)

In order to prevent that, you use a lot of "synchronized"
keywords in Java, which blocks all other accesses to an object.
But the downside is that it can cause deadlocks.

regards,

Hung Jung

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com