Is it possible to observe the current value of a variable with a thread? Example: I have a variable which changes it's value every second and the function check(), which should print "over 10" as soon as the variable is over 10.
Any ideas ?
import threading
import time
def check (timer):
print("thread started")
while True:
if timer > 10:
print("over 10")
timer = 0
threading.Thread(target= check, name= "TimerThread", args=((timer,))).start()
while True:
print(str(timer))
timer = timer + 1
time.sleep(1)