What is the synchronized keyword and its uses? Write code.
Asked in the round 2 stage. Multiple follow-ups.
Implement a thread-safe counter with two methods: increment() and get_value(). Multiple threads may call increment() concurrently, and the final value must be correct. Return the final counter value after all operations complete.
Function signature: def run_counter(operations):
operations is a list of strings, where each string is either "inc" or "get". Simulate the operations in order and return a list of values produced by each "get" operation.
def run_counter(operations):