python多线程(1)

import threading

def thread_job():
    print("This is an added Thread, number is %s" % threading.current_thread())   # 线程的名字

def main():
    add_thread = threading.Thread(target=thread_job)    # 添加的线程
    add_thread.start()                                  # 线程开始

if __name__=='__main__':
    main()

以上的代码 主要是介绍了 如何创建一个线程 和怎样让线程开始。
其中 target=thread_job 是说明 让自定义的这个线程做什么工作的。

猜你喜欢

转载自blog.csdn.net/qq_40258748/article/details/87440549