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()