Created
January 7, 2020 18:12
-
-
Save pgrtiragg/36ca595aad0cdb5d4d8ab4be107c4795 to your computer and use it in GitHub Desktop.
crear hilos en python
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 threading import Thread | |
| import time | |
| class mithread(Thread): | |
| running=True | |
| def __init__(self): | |
| Thread.__init__(self) | |
| self.start() | |
| def run(self): | |
| while self.running: | |
| print('working') | |
| time.sleep(1) | |
| def stop(self): | |
| self.running=False | |
| #self.join() | |
| th=mithread() | |
| while True: | |
| try: | |
| time.sleep(1) | |
| #pass | |
| except KeyboardInterrupt: | |
| th.stop() | |
| print('salida') | |
| break | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment