thread_self.py 304 B

12345678910111213141516171819
  1. import _thread
  2. import time
  3. class Test:
  4. _val = 1
  5. def __init__(self):
  6. self._val = 2
  7. _thread.start_new_thread(self.init, ())
  8. def init(self):
  9. print('self._val:', self._val)
  10. self._val = 3
  11. test = Test()
  12. while test._val != 3:
  13. time.sleep(0.1)
  14. time.sleep(0.1)