多线程:

#-*- 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()

输出结果为:

python,实现多线程

相关文章:

  • 2022-01-09
  • 2022-03-01
  • 2022-12-23
  • 2022-12-23
  • 2021-06-09
  • 2022-02-10
  • 2022-01-02
猜你喜欢
  • 2022-12-23
  • 2021-09-04
  • 2021-11-23
  • 2022-12-23
  • 2022-01-01
  • 2022-02-18
  • 2021-12-11
相关资源
相似解决方案