Thread.exit: spawn threads to watch shared global memory change; : Thread Exit « Thread « Python






Thread.exit: spawn threads to watch shared global memory change;

Thread.exit: spawn threads to watch shared global memory change;
import thread                                   
exitstat = 0 

def child():
    global exitstat
    exitstat = exitstat + 1
    threadid = thread.get_ident()
    print 'Child #:', threadid, exitstat
    thread.exit()
    print 'never reached'

def parent():
    while 1:
        thread.start_new_thread(child, ())
        if raw_input() == 'q': break

parent()

           
       








Related examples in the same category