a = "a"
import time,threading
def thread_func(a):
w = 0
while w < 5:
time.sleep(2)
print("func:" + a)
w += 1
if __name__ == "__main__":
x = threading.Thread(target=thread_func, args=(a))
x.start()
a = input()
func:a
func:a
d
func:d
func:d
func:d
func:a
func:a
d
func:a
func:a
func:a
import threading
import time
a = 'a'
def thread_func():
global a
w = 0
while w < 5:
time.sleep(2)
print("func:" + a)
w += 1
x = threading.Thread(target=thread_func)
x.start()
a = input('Введите новое значение')
import time,threading
class Foo:
a = "a"
def thread_func():
w = 0
while w < 5:
time.sleep(2)
print("func:" + Foo.a)
w += 1
if __name__ == "__main__":
x = threading.Thread(target=thread_func)
x.start()
Foo.a = input('new: ')