def start(self): self.running = True while self.running: passdef shut_down(self): self.running = False嗨,我想知道一种同步变量运行的好方法。我想有一个快速的解决方案,但我不知道会有更好的信号灯,互斥锁或锁。我假设不经常使用shutdown_down。这是我最好的解决方案,但我认为我们可以做得更好。def start(self): self.__lock__.acquire() self.running = True while self.running: self.__lock__.release() self.__lock__.acquire()def shut_down(self): self.__lock__.acquire() self.running = False self.__lock__.release()
添加回答
举报
0/150
提交
取消