Implementing a real-life concurrency scenario programmatically
It is equally important for you to not just understand the concept of concurrency but also experience it by writing concurrent code using basic real-life examples. In this section, we will mimic the example of concurrency that we explained at the beginning of this chapter programmatically using three tasks. These are the early morning routine tasks we mentioned; that is, heating the water, brushing your teeth, and choosing a pair of clothes from your wardrobe.
Since I believe that adding the realistic times it takes to perform each of these tasks is trivial, I'll provide some dummy values in terms of seconds to mimic these tasks. Hence, I chose to represent the time taken for each of these tasks in a matter of seconds just for brevity. This makes it easier for us to run the code faster and understand the results in a neat and organized manner. The following table shows the times I am mimicking for each of the three...