Skip to content

Instantly share code, notes, and snippets.

@fragmede
Created August 14, 2016 17:20
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 fragmede/d08ea867839f43e79908e56e787cf980 to your computer and use it in GitHub Desktop.
Save fragmede/d08ea867839f43e79908e56e787cf980 to your computer and use it in GitHub Desktop.
basic threading example
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