#NEWLINE# def add_num( name ) : #NEWLINE# #INDENT# global num #NEWLINE# while True : #NEWLINE# #INDENT# mylock . acquire ( ) #NEWLINE# print ( ( 'Thread %s locked! num=%s' % ( name , str ( num ) ) ) ) #NEWLINE# if ( num >= 5 ) : #NEWLINE# #INDENT# print ( ( 'Thread %s released! num=%s' % ( name , str ( num ) ) ) ) #NEWLINE# mylock . release ( ) #NEWLINE# thread . exit ( ) #NEWLINE# #UNINDENT# num += 1 #NEWLINE# print ( ( 'Thread %s released! num=%s' % ( name , str ( num ) ) ) ) #NEWLINE# mylock . release ( )