This commit is contained in:
沈瑗杰 2021-01-16 22:21:41 +08:00
parent 9a0737d906
commit 431816ff68

View File

@ -2,8 +2,10 @@
import threading
import time
import os
import sys
import random
class Aclass(threading.Thread):
def __init__(self, dev, ID):
threading.Thread.__init__(self)
@ -23,12 +25,17 @@ class Aclass(threading.Thread):
print(self.id, os.getpid(), os.getppid(), self.running)
time.sleep(1)
def stop(self):
sys.exit()
class dev():
def __init__(self):
self.using = False
self.gets = {'a': False, 'b': False}
self.running = {'a': True, 'b': True}
Dev = dev()
A = Aclass(Dev, 'a')
time.sleep(random.random())
@ -36,6 +43,7 @@ B = Aclass(Dev, 'b')
A.start()
B.start()
print("hmmm")
try:
while True:
In = input()
if In == "stop":
@ -46,3 +54,6 @@ while True:
eval(In)
except:
print(EnvironmentError)
except KeyboardInterrupt:
A.stop()
B.stop()