threading

Grant Edwards invalid at invalid.invalid
Fri Apr 11 12:18:07 EDT 2014


On 2014-04-11, Roy Smith <roy at panix.com> wrote:

> At a high level, threads and coroutines are really very similar.  They 
> are both independent execution paths in the same process.  I guess the 
> only real difference between them is that thread switching is mediated 
> by the operating system, so it can happen anywhere (i.e. at any 
> instruction boundary).

That's only true if your threading system has pre-emption. Python's
does, but not all do. If your threading system is cooperative rather
than preemptive, then using coroutines is completely idential to
threading with 2 threads.

> Coroutines scheduling is handled in user code,

As is cooperative multithreading.

-- 
Grant Edwards               grant.b.edwards        Yow! My BIOLOGICAL ALARM
                                  at               CLOCK just went off ... It
                              gmail.com            has noiseless DOZE FUNCTION
                                                   and full kitchen!!



More information about the Python-list mailing list