单线程, 按次序循环
#coding=utf-8 import time def sayHi(): print("Hello I am Se7eN_HOU") time.sleep(1) if __name__ == "__main__": for i in range(5): sayHi()
多线程,睡眠时其他线程会上,相当于插队,也可以理解为谁先空闲谁先上,这是无序的执行
#coding=utf-8 import threading import time def sayHi(): print("Hello I am Se7eN_HOU") time.sleep(1) if __name__ == "__main__": for i in range(5): t = threading.Thread(target = sayHi) t.start()