Python thread

Prasad, Ramit ramit.prasad at jpmorgan.com
Thu Sep 1 18:21:37 EDT 2011


>So what exactly does threading module do, if it doesn't create a subprocess.
>Does each thread have its own stack and PC.
>What advantage would a threading module provide over sequential execution.

I believe it merely simulates multiple processes through scheduling (like the CPU).

From http://docs.python.org/library/threading.html: CPython implementation detail: Due to the Global Interpreter Lock, in CPython only one thread can execute Python code at once (even though certain performance-oriented libraries might overcome this limitation). If you want your application to make better of use of the computational resources of multi-core machines, you are advised to use multiprocessing. However, threading is still an appropriate model if you want to run multiple I/O-bound tasks simultaneously.

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423




This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  



More information about the Python-list mailing list