Threads vs. continuations

"Martin v. Löwis" martin at v.loewis.de
Tue Feb 19 17:23:12 EST 2008


> I've been doing some thinking, and I've halfway convinced myself of
> the following statement: that threads as implemented by Python (or
> Java) are exactly equivalent to one-shot continuations in Scheme.  Am
> I right?

No. In case of threads, progress can be made in an overlapping
(concurrent), in case of Java even parallel fashion. In particular,
if a thread blocks in a blocking operating system call (e.g. a network
receive operation), other threads can continue. I believe this is not
possible with continuations in Scheme.

In more detail, threads as provided by the operating system underly
a system scheduler: they can be preempted, they have priorities,
and they may voluntarily block. All this is not possible with
continuations.

IOW, threads are more expressive than continuations.

Regards,
Martin



More information about the Python-list mailing list