Threading. Part II – Locks & Timer

Let us consider the block of code below. The threading module and time module would be used for the following example.One function, odd_print(), has been defined to print a number ‘1’, pause for one second, and print the next odd number. This for loop would be repeated five times. Two threads are then started by […]

Threading.

Suppose we have the following code consisting of two functions. Line 3 to 8 defines the odd_print function where it uses a for loop to iterate five times, by first printing the number ‘1’ (Line 6), pauses for one second (Line 7), and adds two to the previous number giving us the next odd number. […]