Created
April 26, 2020 22:37
-
-
Save habbes/65e76015b24bc364ca39e2dbc82e02c5 to your computer and use it in GitHub Desktop.
This file contains 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 multiprocessing | |
import threading | |
import time | |
def thread_runner(val): | |
while True: | |
print("thread ", val) | |
num_cpus = multiprocessing.cpu_count() | |
num_threads = num_cpus * 2 | |
threads = [] | |
for i in range(num_threads): | |
threads.append(threading.Thread(target=thread_runner, args=(i,))) | |
print("Num CPUs", num_cpus) | |
for thread in threads: | |
thread.start() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment