Initial code commit
This commit is contained in:
parent
c9eba67347
commit
167847cd28
5 changed files with 138 additions and 0 deletions
26
src/main.py
Normal file
26
src/main.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# main.py -- run after boot.py
|
||||
|
||||
import _thread
|
||||
import time
|
||||
|
||||
|
||||
def count(name: str, stop: int = 10):
|
||||
i = 0
|
||||
|
||||
while True:
|
||||
print("[{}] {}".format(name, i))
|
||||
i += 1
|
||||
|
||||
if i > stop:
|
||||
break
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
print("[{}] exit".format(name))
|
||||
|
||||
# Start some threads
|
||||
_thread.start_new_thread(count, ('thread1', 5))
|
||||
_thread.start_new_thread(count, ('thread2', 3))
|
||||
|
||||
# Main thread
|
||||
count('main', 10)
|
||||
Loading…
Add table
Add a link
Reference in a new issue