Considering threading, which collection class might introduce higher overhead in managing read and write access?

  • ArrayList
  • HashSet
  • CopyOnWriteArrayList
  • ConcurrentHashMap
In Java, when considering threading and concurrent access, the CopyOnWriteArrayList can introduce higher overhead in managing read and write access. This is because it creates a new copy of the underlying array every time a modification operation is performed (e.g., add or remove). While this ensures thread safety during iterations, it can be inefficient for scenarios with frequent write operations. So, option (c) is correct, with the explanation that CopyOnWriteArrayList is used for thread-safe iteration but may introduce overhead in write operations.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *