# import threading, time, random def f(n): time.sleep(random.random()) print n for i in range(20): t = threading.Thread(target=f, args=(i,)) while 5