Commit 52fafc67 authored by Christian Wander's avatar Christian Wander
Browse files

starting and stopping threads

parent d8892c4f
......@@ -16,3 +16,8 @@ def hello_method():
def threadfun():
return "Started work."
def threadstop():
return "Stopped work"
\ No newline at end of file
import threading
import threading, queue
import time
running = False
def doit():
global running
if running is True:
print(">> DEBUG: already running.")
print(f'>> Starting a thread ...')
x = threading.Thread(target=threaded_function)
running = True
x = threading.Thread(target=threaded_function, daemon=True)
print(f'>> Thread started.')
def stopit():
global running
running = False
def threaded_function():
print(f'>> Doing some work within thread ...')
while running is True:
print(f'>> Doing some work within thread, running={running} ')
print(f'>> Finished work within thread!')
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment