Chapter folders renamed

This commit is contained in:
Karan Solanki
2021-08-13 11:44:51 +05:30
parent d9f3f5b159
commit 1eb709f83a
211 changed files with 0 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
# thread2.py to create daemon and non-daemon threads
from threading import current_thread, Thread as Thread
from time import sleep
def daeom_func():
#print(threading.current_thread().isDaemon())
sleep(3)
print("{}: Hello from daemon".format
(current_thread().name))
def nondaeom_func():
#print(threading.current_thread().isDaemon())
sleep(1)
print("{}: Hello from non-daemon".format(
current_thread().name))
# creating threads
t1 = Thread(target=daeom_func, name="Daemon Thread",daemon=True)
t2 = Thread(target=nondaeom_func, name="Non-Daemon Thread")
# start the threads
t1.start()
t2.start()
print("Exiting the main program")