November 2018
Intermediate to advanced
446 pages
12h 11m
English
In this section, we will implement the preceding situation in an actual Python program. Specifically, we will have two locks (we will call them lock A and lock B), and two separate threads interacting with the locks (thread A and thread B). In our program, we will set up a situation in which thread A has acquired lock A and is waiting to acquire lock B, which has already been acquired by thread B, which is, in turn, waiting for lock A to be released.
If you have already downloaded the code for this book from the GitHub page, go ahead and navigate to the Chapter12 folder. Let us consider the Chapter12/example1.py file, as follows:
# Chapter12/example1.pyimport threadingimport timedef thread_a(): print('Thread A is starting...') ...Read now
Unlock full access