zoukankan      html  css  js  c++  java
  • pyhton3多线程

    from time import ctime,sleep

    def music():
    for i in range(2):
    print ("I was listening to music. %s" %ctime())
    sleep(1)

    def move():
    for i in range(2):
    print ("I was at the movies! %s" %ctime())
    sleep(5)

    if __name__ == '__main__':
    music()
    move()
    print ("all over %s" %ctime())

    import threading
    from time import ctime,sleep

    def music(func):
    for i in range(2):
    print ("I was listening to %s. %s" %(func,ctime()))
    sleep(1)

    def move(func):
    for i in range(2):
    print ("I was at the %s! %s" %(func,ctime()))
    sleep(5)

    if __name__ == '__main__':
    music("test1")
    move("test2")

    print ("all over %s" %ctime())

    #coding=utf-8
    import threading
    from time import ctime,sleep


    def music(func):
    for i in range(2):
    print("I was listening to %s. %s" %(func,ctime()))
    sleep(1)

    def move(func):
    for i in range(2):
    print ("I was at the %s! %s" %(func,ctime()))
    sleep(5)

    threads = []
    t1 = threading.Thread(target=music,args=(u'test1',))
    threads.append(t1)
    t2 = threading.Thread(target=move,args=(u'Test2',))
    threads.append(t2)

    if __name__ == '__main__':
    for t in threads:
    t.setDaemon(True)
    t.start()

    print ("all over %s" %ctime())

    第三部分线程任务处理。

  • 相关阅读:
    C++ CheckListBox
    TreeView查获节点并选中节点
    创建文件自动重命名
    bat
    Edit显示行号
    FindStringExact
    Extended ComboBox添加图标
    C++ Combobox输入时自动完成
    C++ ComboBox基础
    C++ Code_combobox
  • 原文地址:https://www.cnblogs.com/wcLT/p/4305607.html
Copyright © 2011-2022 走看看