Skip to content

Instantly share code, notes, and snippets.

@konz
Created October 13, 2016 16:05
Show Gist options
  • Save konz/2396b29713f45ed08ef15ccff353b85c to your computer and use it in GitHub Desktop.
Save konz/2396b29713f45ed08ef15ccff353b85c to your computer and use it in GitHub Desktop.
Python threading
from random import randint
from threading import Thread
from time import sleep
class DoSomething(Thread):
def run(self):
for i in range(1, 10):
print(i)
sleep(1)
class DoSomethingElse(Thread):
def run(self):
for i in range(1, 10):
print("bla")
sleep(randint(0, 2))
a = DoSomething()
b = DoSomethingElse()
a.start()
b.start()
a.join()
b.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment