beginner, thread & else
Gigs_
gigs at hi.t-com.hr
Thu Dec 14 14:19:17 EST 2006
can someone explain me this code:
----------------------------------
import thread
stdoutmutex = thread.allocate_lock()
exitmutexes = [0] * 10
def counter(myId, count):
for i in range(count):
stdoutmutex.acquire()
print '[%s] => %s' % (myId, i)
stdoutmutex.release()
exitmutexes[myId] = 1 # signal main thread
for i in range(10):
thread.start_new(counter, (i, 100))
while 0 in exitmutexes:
pass
print 'Main thread exiting.'
-----------------------------------
thread.start_new(counter, (i, 100)) is running counter function.
Is counter function and while statement executed in same time (other
things i understand, but can't get into this)?
thanks
More information about the Python-list
mailing list