I have a variable. That variable will only ever be calculated by one continuously running thread, others will be able to access it but not adjust it in any way. The other threads will not cooperate with each other, so it doesn't matter whether one of the other thread thinks that a = 3 and other that a = 2. Here is a simple non-working example that demostrates what I mean:
number = 0
def thread_target():
while True:
global number
number = random.randint(1,60)
def thread_target2():
global number
for i in range(10):
print(number)
sleep(1)
t1 = Thread(target=thread_target)
t2 = Thread(target=thread_target2())
t1.start()
t2.start()
t2.join()
What is the "intended" tool/syntax for having something like this work?