Skip to content
This repository was archived by the owner on Feb 9, 2025. It is now read-only.

Commit b5b7819

Browse files
committed
feat: Added another example
0 parents  commit b5b7819

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.swp
2+
*.vscode
3+
*.pyc
4+
*__pycache__

time_counting_example.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python3
2+
3+
import threading
4+
import os
5+
import sys
6+
import time
7+
8+
def print_time(thread_name, delay):
9+
count = 0
10+
while count < 5:
11+
time.sleep(delay)
12+
count += 1
13+
print ("%s: %s" % (thread_name, time.ctime(time.time())))
14+
15+
def main():
16+
threads = [2]
17+
print("Starting threads")
18+
thread1 = threading.Thread(target=print_time, kwargs={"thread_name":"Thread-1", "delay":2})
19+
thread2 = threading.Thread(target=print_time, kwargs={"thread_name":"Thread-2", "delay":4})
20+
thread1.start()
21+
thread2.start()
22+
thread1.join()
23+
thread2.join()
24+
return 0
25+
26+
if __name__ == "__main__":
27+
main()
28+

0 commit comments

Comments
 (0)