just to be clear i dont have a specific example because using the way various "how to"'s suggested to implement suited my needs until now and i did not encounter any problems regarding locks, but the usage of locks in python did raise the following question
it seems that calling lock.acquire() does not require specifying a resource to lock which made me wonder how do python locks know which object or resource to lock?
import time import thread
def myfunction(string,sleeptime,lock,*args):
while 1: #entering critical section
lock.acquire()
print string," Now Sleeping after Lock acquired for ",sleeptime
time.sleep(sleeptime)
print string," Now releasing lock and then sleeping again"
lock.release() #exiting critical section
time.sleep(sleeptime) # why?
lock=thread.allocate_lock()
thread.start_new_thread(myfunction,("Thread No:1",2,lock))
thread.start_new_thread(myfunction,("Thread No:2",2,lock))