如何使用线程中来自不同线程的函数中的值?

时间:2018-11-04 19:26:14

标签: python multithreading loops delay

我有两个函数,每个函数都希望以不同的延迟循环,因此我使用线程。如何在function2中使用value_function1(在function1中计算)?

def function1():
    while True:
        value_function1 = #gets value from API
        time.sleep(60)

def function2():
    while True:
        #want to use the value_function1 here the last time it was calculated in function1
        time.sleep(10)

thread_function1 = threading.Thread(target=function1)
thread_function1.start()

thread_function2 = threading.Thread(target=function2)
thread_function2.start()

0 个答案:

没有答案