Last active
August 20, 2020 03:39
-
-
Save im-noob/1f4066c7dd844cdd3222d1f46416be25 to your computer and use it in GitHub Desktop.
Find Maximum No thread your system can have in python..
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 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