Answers for "run two similar functions simultaneously python"

0

run two similar functions simultaneously python

#use threading instead of multiprocessing
#by @devDavmen
## EXAMPLE 101 ##
import threading

def a():
    print("Function a is running at time: " + str(int(time.time())) + " seconds.")

    
def b():
    print("Function b is running at time: " + str(int(time.time())) + " seconds.")

threading.Thread(target=a).start() 
## OUTPUT >>>  Function a is running at time: 1585338789 seconds.
threading.Thread(target=b).start() 
## OUTPUT >>>  Function b is running at time: 1585338789 seconds.


## EXAMPLE 2 ##
import threading

def f():
    print "abc"

thread = threading.Thread(target=f)
thread.start()
## OUTPUT >> abc
Posted by: Guest on September-02-2021

Code answers related to "run two similar functions simultaneously python"

Python Answers by Framework

Browse Popular Code Answers by Language