In the preceding code, we define a simple function called executeThread which takes in i as its only parameter. Within this function, we simply call the time.sleep() function and pass in a randomly generated int between 1 and 10.
We then go on to declare a for loop that loops from 1 to 10, which creates a thread object and then starts it while passing in i to our thread's args. When you run this script, you should see something like this:
$ python3.6 00_startingThread.py
Thread 0 started
Active Threads: [<_MainThread(MainThread, started 140735793988544)>, <Thread(Thread-1, started 123145335930880)>]
Thread 1 started
Active Threads: [<_MainThread(MainThread, started 140735793988544)>, <Thread(Thread-1, started 123145335930880)>, <Thread(Thread-2, started 123145341186048)>]
Thread 2 started
Active Threads: [<_MainThread(MainThread, started 140735793988544)>, <Thread(Thread-1, started 123145335930880)>, <Thread(Thread-2, started 123145341186048)>, <Thread(Thread-3, started 123145346441216)>]