创建threading.Thread对象

def printHello():

    while True:

        print("This is the hello threading...")

        time.sleep(1)

def printNihao():

    while True:

        print("This is the Nihao threading...")

        time.sleep(2)

if __name__ == '__main__':

    t1 = threading.Thread(target=printHello)

    t2 = threading.Thread(target=printNihao)

    t1.setDaemon(False)

    t2.setDaemon(False)

    t1.start()

    t2.start()

    print("main threading ended...")

你可能感兴趣的:(java,servlet,javascript)