Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,885 questions

51,811 answers

573 users

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
...