Nick includes this before he gets down to coding with time
Let's look at an analogy. Say you want to cook breakfast. You need to cook:
Coffee - takes 1 minute
Bacon - takes 2 minutes
Eggs - takes 3 minutesNow a seasoned cook would NOT do this:
Put coffee on. Stare at watch until 1 minute has elapsed. Pour coffee.
Cook bacon. Stare at watch until 2 minutes have elapsed. Serve bacon.
Fry eggs. Stare at watch until 3 minutes have elapsed. Serve eggs.The flaw in this is that whichever way you do it, something is going to be cooked too early (and get cold).
In computer terminology this is blocking. That is, you don't do anything else until the one task at hand is over.
What you are likely to do is this:
Start frying eggs. Look at watch and note the time.
Glance at watch from time to time. When one minute is up then ...
Start cooking bacon. Look at watch and note the time.
Glance at watch from time to time. When another minute is up then ...
Put coffee on. Look at watch and note the time.
When 3 minutes are up, everything is cooked. Serve it all up.In computer terminology this is non-blocking. That is, keep doing other things while you wait for time to be up.
I like his explanations and he is thorough with the code.