Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -------------------------------------------
- # (c) 2020 Fouad AMANSOUR fd.amansour@gmail.com
- # This code can run two separate functions simultaneously using Thread
- # -------------------------------------------
- import time
- from threading import Thread
- def firstFunction():
- while True:
- print('The 1st "while loop" is currently running')
- time.sleep(1)
- def secondFunction():
- while True:
- print('The 2nd "while loop" is currently running')
- time.sleep(1)
- thread1 = Thread(target = firstFunction)
- thread2 = Thread(target = secondFunction)
- thread1 .start()
- thread2.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement