Skip to content

Instantly share code, notes, and snippets.

@im-noob
Last active August 20, 2020 03:39
Show Gist options
  • Save im-noob/1f4066c7dd844cdd3222d1f46416be25 to your computer and use it in GitHub Desktop.
Save im-noob/1f4066c7dd844cdd3222d1f46416be25 to your computer and use it in GitHub Desktop.
Find Maximum No thread your system can have in python..
import threading
from time import sleep
from threading import Thread
def doSleep():
sleep(300)
i = 0
while True:
i += 1
try:
print('Running:',i)
t = Thread(target=doSleep)
t.start()
print('active thread count:',threading.active_count())
except:
print('------------------------ EXIT ------------------')
print("Maximum No of Threads:",i)
print('active thread count:',threading.active_count())
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment