explain CopyOnwriteArraySet.

Pragya Keshap answered on February 22, 2023 Popularity 2/10 Helpfulness 1/10

Contents


More Related Answers

  • python copy deep arrays without reference
  • Python NumPy copyto function example copy elements from a source array to a destination array.
  • python numpy array reference or copy

  • explain CopyOnwriteArraySet.

    0

    It shares some properties of Set and also has its own properties as listed:

    The internal implementation of CopyOnWriteArraySet is CopyOnWriteArrayList only.

    Multiple Threads are able to perform update operations simultaneously but for every update operation, a separate cloned copy is created. As for every update a new cloned copy will be created which is costly. Hence if multiple update operations are required then it is not recommended to use CopyOnWriteArraySet.

    While one thread iterating the Set, other threads can perform updation, here we won’t get any runtime exception like ConcurrentModificationException.

    An Iterator of CopyOnWriteArraySet class can perform only read-only and should not perform the deletion, otherwise, we will get Run-time exception UnsupportedOperationException.

    Use CopyOnWriteArraySet in applications in which set sizes generally stay small, read-only operations vastly outnumber mutative operations, and you need to prevent interference among threads during traversal.

    CopyOnWriteArraySet helps in minimizing programmer-controlled synchronization steps and moving the control to inbuilt, well-tested APIs.


    https://www.geeksforgeeks.org/copyonwritearrayset-in-java/

    Popularity 2/10 Helpfulness 1/10 Language java
    Source: Grepper
    Tags: explain java
    Link to this answer
    Share Copy Link
    Contributed on Feb 22 2023
    Pragya Keshap
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.