Created
October 13, 2016 16:05
-
-
Save konz/2396b29713f45ed08ef15ccff353b85c to your computer and use it in GitHub Desktop.
Python threading
This file contains hidden or 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
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