Race Condition in Python

Master Python with 70+ Hands-on Projects and Get Job-ready - Learn Python

Program 1

# Program for Racing condition
import time
from  threading import *
def printable(n):
    for i in range (1,11):
        print(n*i)
        print()
        time.sleep(1)

#Calling (Main Thread)
T1=Thread(target=printable,args=(5,),name="First " )
T2=Thread(target=printable,args=(7,),name="Second " )
T3=Thread(target=printable,args=(9,),name="Second " )
T1.start()
T2.start()
T3.start()
T1.join()
T2.join()
T3.join()
print("Main Thread End ")
# print(T1.getName())
# print(T2.getName())

 

Your 15 seconds will encourage us to work even harder
Please share your happy experience on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *