1# stress test for creating many threads 2 3try: 4 import utime as time 5except ImportError: 6 import time 7import _thread 8 9 10def thread_entry(n): 11 pass 12 13 14thread_num = 0 15while thread_num < 500: 16 try: 17 _thread.start_new_thread(thread_entry, (thread_num,)) 18 thread_num += 1 19 except MemoryError: 20 pass 21 22# wait for the last threads to terminate 23time.sleep(1) 24print("done") 25