1
2
3
4
5
6
Use the "Verify Solution" button to get AI feedback on your Java code.
Implement a ThreadSafeCounter class that provides a getValue() method to retrieve the current count and an increment() method to increase the count by one.
The primary requirement is that the increment() operation must be thread-safe. When multiple threads concurrently call increment(), the final count should accurately reflect the total number of increments performed.
Consider the common pitfalls of shared mutable state in concurrent environments and design your solution to prevent race conditions.