def _Counter(lock, state, me):
    'Thread function for acquiring locks.\n\n  '
    counts = state.counts
    verify = state.verify
    while True:
        lock.acquire()
        try:
            verify[me] = 1
            counts[me] += 1
            state.total_count += 1
            if ((state.total_count % 1000) == 0):
                sys.stdout.write((' %8d\r' % state.total_count))
                sys.stdout.flush()
            if (sum(verify) != 1):
                print('Inconsistent state!')
                os._exit(1)
            verify[me] = 0
        finally:
            lock.release()
Thread function for acquiring locks.
def _Counter(lock, state, me):
    '\n\n  '
    counts = state.counts
    verify = state.verify
    while True:
        lock.acquire()
        try:
            verify[me] = 1
            counts[me] += 1
            state.total_count += 1
            if ((state.total_count % 1000) == 0):
                sys.stdout.write((' %8d\r' % state.total_count))
                sys.stdout.flush()
            if (sum(verify) != 1):
                print('Inconsistent state!')
                os._exit(1)
            verify[me] = 0
        finally:
            lock.release()