# -*- coding: utf-8 -*- import threading, time def testThread(id): for i in range(10): print 'thread(%s) --> %s' % (id, i) time.sleep(0) # context switching testThreads = [] for i in range(3): th = threading.Thread(target=testThread, args=(i,)) th.start() testThreads.append(th) for th in testThreads: th.join() print 'end'