Concurrent access to a shared variable by multiple threads with and without using a mutex