-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththreadTests.py
More file actions
26 lines (22 loc) · 777 Bytes
/
Copy paththreadTests.py
File metadata and controls
26 lines (22 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import logging
import threading
import time
class ThreadTests:
def __init__(self):
self.lock = threading.Lock()
def thread_function(self, name):
self.lock.acquire()
logging.info("Function %s: starting", name)
time.sleep(2)
logging.info("Function %s: finishing", name)
self.lock.release()
format = "%(asctime)s: %(message)s"
logging.basicConfig(format=format, level=logging.INFO,
datefmt="%H:%M:%S")
logging.info("Main : create and start thread %s.", "szukanie celu")
x = threading.Thread(target=thread_function, args=("szukanie celu",))
y = threading.Thread(target=thread_function, args=("centrowanie kamery",))
x.start()
y.start()
x.join()
y.join()