pikapython/test/python/_thread/thread_self.py

19 lines
288 B
Python
Raw Normal View History

2023-02-28 10:59:53 +08:00
import _thread
import time
class Test:
_val = 1
def __init__(self):
self._val = 2
_thread.start_new_thread(self.init, ())
def init(self):
print('self._val:', self._val)
self._val = 3
test = Test()
while test._val != 3:
time.sleep(0.5)