1 import threading 2 import time 3 4 5 class write_a(threading.Thread): 6 def run(self): 7 for x in range(3): 8 print("写字%s" % threading.current_thread()) 9 time.sleep(1) 10 11 12 class draw(threading.Thread): 13 def run(self): 14 for x in range(3): 15 print("画画%s" % threading.current_thread()) 16 time.sleep(1) 17 18 19 def main(): 20 t1 = write_a() 21 t2 = draw() 22 t1.start() 23 t2.start() 24 25 if __name__ == '__main__': 26 main()