Skip to content

Instantly share code, notes, and snippets.

@isidroamv
Created January 30, 2018 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isidroamv/bb4653cb28b1f12cc865cca9c102c4d0 to your computer and use it in GitHub Desktop.
Save isidroamv/bb4653cb28b1f12cc865cca9c102c4d0 to your computer and use it in GitHub Desktop.
A loop using Thread
from threading import Thread
import random
import time
import requests
def send_configurations(n=1, n2=2):
time.sleep(random.randint(1, 10))
print(n)
for n in range(10):
d = {
'n': n,
'n2': 1
}
Thread(target=send_configurations, kwargs=(d)).start()
apps = []
def printer(id):
for n in range(10):
print(id)
for n in range(4):
p = Thread(target=printer, args=(n,))
apps.append((printer, p, "printer"))
p.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment