Skip to content

Instantly share code, notes, and snippets.

@GitHub30
Last active August 28, 2022 15:29
Show Gist options
  • Save GitHub30/4ee30d129f0a2cf6280197c68767898f to your computer and use it in GitHub Desktop.
Save GitHub30/4ee30d129f0a2cf6280197c68767898f to your computer and use it in GitHub Desktop.
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))
import _thread
import time
def mythread():
time.sleep(10)
_thread.exit()
_thread.start_new_thread(mythread, ())
# sleep 10s
# _thread.start_new_thread(mythread, ())
@GitHub30
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment