Skip to content

Instantly share code, notes, and snippets.

@pitrou
Last active Mar 16, 2021
Embed
What would you like to do?
import sys
import threading
NLOOPS = 10
NTHREADS = 30
def t1():
from concurrent.futures import ThreadPoolExecutor
def t2():
from concurrent.futures.thread import ThreadPoolExecutor
def main():
for j in range(NLOOPS):
threads = []
for i in range(NTHREADS):
threads.append(threading.Thread(target=t2 if i % 1 else t1))
for thread in threads:
thread.start()
for thread in threads:
thread.join()
sys.modules.pop('concurrent.futures', None)
sys.modules.pop('concurrent.futures.thread', None)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment