Last active
August 28, 2022 15:29
-
-
Save GitHub30/4ee30d129f0a2cf6280197c68767898f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import _thread | |
import time | |
def mythread(): | |
time.sleep(1000) | |
def main(): | |
threads = 0 #thread counter | |
y = 1000000 #a MILLION of 'em! | |
for i in range(y): | |
try: | |
x = _thread.start_new_thread(mythread, ()) | |
threads += 1 #thread counter | |
except RuntimeError: #too many throws a RuntimeError | |
break | |
print("{} threads created.\n".format(threads)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import _thread | |
import time | |
def mythread(): | |
time.sleep(10) | |
_thread.exit() | |
_thread.start_new_thread(mythread, ()) | |
# sleep 10s | |
# _thread.start_new_thread(mythread, ()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://forum.micropython.org/viewtopic.php?t=11433&p=62551