Created
August 14, 2016 17:20
-
-
Save fragmede/d08ea867839f43e79908e56e787cf980 to your computer and use it in GitHub Desktop.
basic threading example
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
import threading | |
import time | |
class Continuous(threading.Thread): | |
def __init__(self): | |
super(Continuous, self).__init__() | |
self.die = False | |
self.info = 0 | |
def run(self): | |
while not self.die: | |
print 'i am sending continuously', self.info | |
time.sleep(.5) | |
if __name__ == '__main__': | |
c = Continuous() | |
c.start() | |
time.sleep(1) | |
c.info = 42 | |
time.sleep(1) | |
c.die = True | |
c.join() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment