Concurrency with multithreading

In most modern processor systems, the use of multithreading is commonplace. With CPUs coming with more than one core and technologies such as hyper-threading, which allows a single core to run multiple threads at the same time, application developers do not waste a single chance to exploit the advantages provided by these technologies.

Python as a programming language supports the implementation of multithreading through the use of a threading module that allows developers to exploit thread-level parallelism in the application.

The following example showcases how a simple program can be built using the threading module in Python:

# simple_multithreading.pyimport threadingclass SimpleThread(threading.Thread): ...

Get Hands-On Enterprise Application Development with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.