What is the primary difference between `ConcurrentHashMap` and `HashMap` in Java?
`HashMap` is thread-safe, but `ConcurrentHashMap` performs better when multiple threads are involved in concurrent operations.
Thatâ€™s partially correct. `HashMap` is not thread-safe, whereas `ConcurrentHashMap` is thread-safe and optimized for concurrent access.
Can you explain why `HashMap` is not thread-safe and what would happen in a multithreaded scenario?