forked from x4nth055/pythoncode-tutorials
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnormal_thread.py
More file actions
Latest commit
15 lines (13 loc) · 413 Bytes
/
Copy pathnormal_thread.py
File metadata and controls
15 lines (13 loc) · 413 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
importthreading
importtime
deffunc():
whileTrue:
print(f"[{threading.current_thread().name}] Printing this message every 2 seconds")
time.sleep(2)
# initiate the thread to call the above function
normal_thread=threading.Thread(target=func, name="normal_thread")
# start the thread
normal_thread.start()
# sleep for 4 seconds and end the main thread
time.sleep(4)
# the main thread ends