Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python kill all threads

#setting thread as a daemon thread

import threading
import time
import sys
def exfu():
    while True:
        time.sleep(0.5)
        print('Thread alive, but it will die on program termination')
x = threading.Thread(target=exfu)
x.daemon = True
x.start()
time.sleep(2)
sys.exit()
Source by www.delftstack.com #
 
PREVIOUS NEXT
Tagged: #python #kill #threads
ADD COMMENT
Topic
Name
4+2 =