share a global variable in multi threading doesn't work in python
Question: I am trying to share a global variable between two function in `python`. They
are working at the same time whith multitreading. the problem is that its like
the global variable is not global at all here is my code:

    
    
    import threading as T
    import time
    
    nn = False
    def f1(inp):
        global nn
        while True:
            inp=inp+1
            time.sleep(0.5)
            print 'a-'+str(inp)+"\n"
            if inp > 10:
                nn=True
                print nn
    
    def f2(inp):
        inp=int(inp)
        while nn:
            inp=inp+1
            time.sleep(1)
            print 'b-'+str(inp)+"\n"
    
    t1= T.Thread(target=f1, args = (1,))
    t1.daemon = True
    t1.start()
    t2= T.Thread(target=f2, args = (1,))
    t2.daemon = True
    t2.start()
    


Answer: The problem is that `while nn` only gets evaluated once. When it is, it
happens to be `False` because f1 has not yet made it `True` so `f2` finishes
running. If you initialize `nn = True` you'll see it is being accessed by both
`f1` and `f2`

