Skip to content

Instantly share code, notes, and snippets.

@habbes
Created April 26, 2020 22:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save habbes/65e76015b24bc364ca39e2dbc82e02c5 to your computer and use it in GitHub Desktop.
Save habbes/65e76015b24bc364ca39e2dbc82e02c5 to your computer and use it in GitHub Desktop.
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