python,实现多线程
多线程:
#-*- coding:utf-8 -*-
import threading
import time
def target():
print("the current threading %s is runing"%(threading.current_thread().name))
seed = ["a", "b", "c"]
for each in seed:
print('the current threading %s is runing,hello:'%(threading.current_thread().name),each)
time.sleep(2)
print("the current threading %s is ended"%(threading.current_thread().name))
if __name__ == '__main__':
threads = []
thread1 = threading.Thread(target=target)
threads.append(thread1)
thread2 = threading.Thread(target=target)
threads.append(thread2)
thread3 = threading.Thread(target=target)
threads.append(thread3)
for t in threads:
t.start()
输出结果为: