Skip to content

Commit d288c19

Browse files
authored
Merge pull request #98 from SummerGGift/update_doc
【更新】thread 示例程序
2 parents ef00b4d + 75b7680 commit d288c19

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

examples/basic/_thread_example.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@
1010

1111
import _thread
1212
import utime as time
13+
import gc
1314

1415
def testThread():
15-
while True:
16-
print("Hello from thread")
17-
time.sleep(2)
16+
count = 0
17+
while (count < 9):
18+
print("Hello rt-thread!")
19+
count += 1
1820

19-
_thread.start_new_thread(testThread, ())
20-
while True:
21-
pass
21+
print("Thread exit!")
22+
gc.collect() # Free the memory space requested by the thread
23+
24+
# TestThread thread is created with an empty argument
25+
_thread.start_new_thread(testThread, ())

0 commit comments

Comments
 (0)