import time, threading
# Try changing the 2 in the following line....
sa = threading.Semaphore(0)
def myPrint(x):
    sa.acquire()
    print("Semaphore acquired by thread number ",x)
    time.sleep(1)
    print ('This is thread number ',x)
    sa.release()
    print("Semaphore released by thread number ",x)
    
for y in range(10):
    t=threading.Thread(target=myPrint, args=(y,))
    t.start()
