_thread_example.py 548 B

12345678910111213141516171819202122232425
  1. #
  2. # Copyright (c) 2006-2019, RT-Thread Development Team
  3. #
  4. # SPDX-License-Identifier: MIT License
  5. #
  6. # Change Logs:
  7. # Date Author Notes
  8. # 2019-06-13 SummerGift first version
  9. #
  10. import _thread
  11. import utime as time
  12. import gc
  13. def testThread():
  14. count = 0
  15. while (count < 9):
  16. print("Hello rt-thread!")
  17. count += 1
  18. print("Thread exit!")
  19. gc.collect() # Free the memory space requested by the thread
  20. # TestThread thread is created with an empty argument
  21. _thread.start_new_thread(testThread, ())