I can't seem to change the x or y values in the code below. I thought the second thread will wait until the the calculation is complete?
I don't know what fundamentally I'm doing wrong here?
from threading import Event, Thread
import numpy as np
def test():
x = [0, 1]
y = [1, 3]
def calc_callback(ev):
x = np.linspace(-5, 5, 100)
y = np.sin(x)/x
ev.set()
def display_callback(ev):
ev.wait()
print(x)
print(y)
completion_event = Event()
Thread(target=calc_callback, args=[completion_event]).start()
Thread(target=display_callback, args=[completion_event]).start()
if __name__ == '__main__':
test()