How would you handle race conditions in Python?
Implement thread_safe_total(increments), where each list element is the number of times one worker thread must increment a shared counter. Protect the compound read-modify-write operation so the returned total is deterministic.
increments is a list of non-negative integers. Return one integer equal to the sum of all elements after every worker completes.
def thread_safe_total(increments):