python two while loops at same time

Solutions on MaxInterview for python two while loops at same time by the best coders in the world

showing results for - "python two while loops at same time"
Till
27 Oct 2019
1import threading
2import time
3
4def infiniteloop1():
5    while True:
6        print('Loop 1')
7        time.sleep(1)
8
9def infiniteloop2():
10    while True:
11        print('Loop 2')
12        time.sleep(1)
13
14thread1 = threading.Thread(target=infiniteloop1)
15thread1.start()
16
17thread2 = threading.Thread(target=infiniteloop2)
18thread2.start()
19