Problems with threads

Learn about the limitations of using threads for concurrent programming in Python and get to know some of the alternative approaches.

Threads can be useful if appropriate care is taken to manage shared memory, but modern Python programmers tend to avoid them for several reasons. As we’ll see, there are other ways to code concurrent programming that are receiving more attention from the Python community. Let’s discuss some of the pitfalls before moving on to alternatives to multithreaded applications.

Shared memory

The main problem with threads is also their primary advantage. Threads have access to all the process memory and thus all the variables. A disregard for the shared state can too easily cause inconsistencies.

Get hands-on with 1200+ tech skills courses.