<s> from thread import start_new_thread <EOL> import time <EOL> work = [ ] <EOL> done = [ ] <EOL> def run ( num ) : <EOL> for i in xrange ( num ) : <EOL> t = work . pop ( ) <EOL> work . append ( t - <NUM_LIT:1> ) <EOL> done . append ( num ) <EOL> print "<STR_LIT>" <EOL> nthreads = <NUM_LIT:2> <EOL> N = <NUM_LIT> <EOL> for i in xrange ( nthreads ) : <EOL> work . append ( N ) <EOL> for i in xrange ( nthreads ) : <EOL> t = start_new_thread ( run , ( N , ) ) <EOL> while len ( done ) < nthreads : <EOL> time . sleep ( <NUM_LIT:0> ) <EOL> assert sum ( work ) == <NUM_LIT:0> </s>
