Add the counter with mutex-based synchronization for use in threaded environments