Uses simple shared global data to know when threads are done in parent/main thread : Thread Synchronize : Thread PYTHON examples


PYTHON examples » Thread » Thread Synchronize »

 

Uses simple shared global data to know when threads are done in parent/main thread


Uses simple shared global data to know when threads are done in parent/main thread

import thread

def counter(myId, count):
    for i in range(count)
        stdoutmutex.acquire()
        print '[%s=> %s' % (myId, i)
        stdoutmutex.release()
    exitmutexes[myId1  # signal main thread

stdoutmutex = thread.allocate_lock()
exitmutexes = []
for i in range(10):
    exitmutexes.append(0)
    thread.start_new(counter, (i, 100))

while in exitmutexes: pass
print 'Main thread exiting.'


           
       



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Thread
» Thread Synchronize