Serialized by the mutex lock

2019-06-16 02:07栏目:技术创新

import thread, time

def counter(myId, count):
    for i in range(count): 
        mutex.acquire()
        print 'thread number %d reporting in at %d...' % (myId, time.clock())
        time.sleep(1)
        mutex.release()

print time.clock()
mutex = thread.allocate_lock()
for i in range(5):
    thread.start_new(counter, (i, 3))

time.sleep(20) 
print 'Main thread exiting.'

版权声明:本文由新浦京娱乐站_新浦京娱乐场官网_新浦京娱乐发布于技术创新,转载请注明出处:Serialized by the mutex lock