1
2
3
4
5
6
Use the "Verify Solution" button to get AI feedback on your Java code.
Implement a thread-safe counter that can be incremented concurrently by multiple threads without data corruption. The increment() method must ensure that the counter's value is always consistent, even under heavy contention. Your task is to modify the provided SafeCounter class to make its increment() method thread-safe. You should not modify the getValue() method.