Skip to content

Instantly share code, notes, and snippets.

@pgrtiragg
Created January 7, 2020 18:12
Show Gist options
  • Select an option

  • Save pgrtiragg/36ca595aad0cdb5d4d8ab4be107c4795 to your computer and use it in GitHub Desktop.

Select an option

Save pgrtiragg/36ca595aad0cdb5d4d8ab4be107c4795 to your computer and use it in GitHub Desktop.
crear hilos en python
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