No output from threads

Alan Kennedy alanmk at hotmail.com
Fri Apr 5 04:35:02 EST 2002


Jeff Shannon:

> > A word of warning, though -- you may not be getting much usage of 
> > your second processor.  Python itself has a Global Interpreter 
> > Lock, forcing only one Python thread to be running at any given 
> > time.

David Bolen
> Actually, threads can certainly run on any of multiple processors,
> since they should be scheduled by the OS, but they can't be
> interpreting Python code simultaneously.  But that doesn't stop them
> from executing on different processors when they do get control of the
> GIL.  

An alternative approach which will make use of multiple processors is
jython, which, AFAIK, does not have a Global Interpreter Lock. So in
Jython, multiple python threads can run simultaneously on multiple
processors, as long as they don't access the same python objects.

Of course, you're unlikely to get a speed improvement with two
processors running jython threads versus one processor running cpython
threads, because jython is a virtual machine inside a virtual machine.

But I'd imagine that if you had 4+ processors, you'd start seeing
superior performance from jython ;-)

Regards,

Alan Kennedy.



More information about the Python-list mailing list