Professional Documents
Culture Documents
Practical 5: MR Andrew Cook 21 February 2022
Practical 5: MR Andrew Cook 21 February 2022
Mr Andrew Cook
21 February 2022
Introduction
The focus of this practical is on basic concurrency operations and getting com-
fortable with the Threading module and specifically the Thread class within
it.
Task 1
Try the examples given in Lecture 5b.
What happens if you delete the Thread.join() commands?
Change how long each task waits - perhaps by subtracting the thread number
from a fixed value. Do the processes complete in different orders now?
Task 2
In lecture 5a we outlined a scenario where Concurrency might be useful by
describing the process of cooking a breakfast.
2.2: Concurrency
Using the Threading module and Thread object re-run the above program using
concurrency.
How long does this new program take to complete?
1
2.3: Object-Oriented approach
Extend the Thread class to produce a subclass for each of the three tasks in
making breakfast.