Hi All,
can someone help me how to call python function with args in multithreading. the below code is not able to create multiple threads.
import threading
lock = threading.Lock()
def first_function():
for i in range(5):
lock.acquire()
print (‘lock acquired’)
print (‘Executing the first funcion’)
lock.release()
def second_function():
for i in range(5):
lock.acquire()
print (‘lock acquired’)
print (‘Executing the second funcion’)
lock.release()
if name==“main”:
thread_one = threading.Thread(target=first_function)
thread_two = threading.Thread(target=second_function)
print("Thread start time:-", datetime.datetime.now())
print("Thread1 start time:-", datetime.datetime.now())
thread_one.start()
print("Thread1 end time:-", datetime.datetime.now())
print("Thread2 start time:-", datetime.datetime.now())
thread_two.start()
print("Thread2 end time:-", datetime.datetime.now())
thread_one.join()
thread_two.join()