Created
February 28, 2010 15:11
-
-
Save hktechn0/317628 to your computer and use it in GitHub Desktop.
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
#!/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