python
import threading
class Counter:
def __init__(self):
self.lock = threading.Lock()
self.count = 0
def increment(self):
with self.lock:
self.count += 1
def get_count(self):
with self.lock:
return self.count
counter = Counter()
def handle_request(request):
counter.increment()
def process_requests():
threads = []
for request in requests:
thread = threading.Thread(target=handle_request, args=(request,))
threads.append(thread)
thread.start()
for thread in threads:
thread.join()
if __name__ == "__main__":
process_requests()