class Task(object): def __init__(self, task): self._alive = True self.task = task def is_alive(self): return self._alive def done(self): with threading.Lock(): self._alive = False