How to repeating functionality using threads (execute threads endlessly) in Python

1 Answer

0 votes
from threading import *
import time


def function1():
    while True:
        print("function1()")
        time.sleep(5)


def function2():
    while True:
        print("function2()")
        time.sleep(5)


f1 = Timer(4.0, function1)
f2 = Timer(3.0, function2)

f1.start()
f2.start()


'''
run:
  
function2()
function1()
function2()
function1()
function2()
function1()
function2()
function1()
...

'''

 



answered Jun 25, 2018 by avibootz
...