Created
November 13, 2018 06:23
-
-
Save cftang0827/1c2f319a7517a3dc2f75394eb1b29c4f to your computer and use it in GitHub Desktop.
This file contains 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
import time | |
import threading | |
class p: | |
def __init__(self): | |
self.flag = True | |
self.thread = threading.Thread(target=self.show) | |
self.thread.start() | |
def show(self): | |
while True: | |
if self.flag: | |
print("Hello") | |
else: | |
print("dead") | |
break | |
p1 = p() | |
time.sleep(3) | |
p1.flag = False | |
print(p1.thread.is_alive()) | |
p1.thread.join() | |
print(p1.thread.is_alive()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment