Skip to content

Instantly share code, notes, and snippets.

@hktechn0
Created February 28, 2010 15:11
Show Gist options
  • Save hktechn0/317628 to your computer and use it in GitHub Desktop.
Save hktechn0/317628 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import threading
class main(threading.Thread):
def __init__(self, sec):
threading.Thread.__init__(self)
self.event = threading.Event()
self.sleep = sec
self.setDaemon(True)
def run(self):
while True:
self.event.wait(self.sleep)
print "loop"
self.event.clear()
if __name__ == "__main__":
a = main(10)
a.start()
while True:
if "b" == raw_input():
a.event.set()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment