Home  >  Q&A  >  body text

Python executes two functions at the same time

I have customized two functions now

def test():

while True:
    ...
    ...

def test1():

while True:
    ...
    ...

These two functions are two functions in an infinite loop. Now I want these two functions to be executed simultaneously in the same PY file. I don’t know if the experts have any good solutions. Newbie asking for advice.

欧阳克欧阳克2581 days ago848

reply all(1)I'll reply

  • 为情所困

    为情所困2017-06-22 11:54:20

    Multiple threading

    import threading
    
    threading.Thread(target= test).start()
    threading.Thread(target=test1).start()

    reply
    0
  • Cancelreply