Content deleted Content added
→CopyOnWriteArrayList class: fixed grammar |
→CopyOnWriteArrayList class: Add in-line citation |
||
Line 126:
====CopyOnWriteArrayList class====
The {{code|CopyOnWriteArrayList}} extends the {{code|Object}} class, and does not extend any other classes. {{code|CopyOnWriteArrayList}} allows for thread-safety without performing excessive synchronization.{{sfn|Bloch|2018|loc=Chapter §11 Item 79: Avoid excessive synchronization|pp=317-322}}
In some scenarios, synchronization is mandatory. For example, if a method modifies a static field, and the method must be called by multiple threads, then synchronization is mandatory and concurrency utilities such as {{code|CopyOnWriteArrayList}} should not be used.{{sfn|Bloch|2018|loc=Chapter §11 Item 79: Avoid excessive synchronization|pp=317-322}}
However synchronization can incur a performance overhead. For scenarios where synchronization is not mandatory, then the {{code|CopyOnWriteArrayList}} is a viable, thread-safe alternative to synchronization that leverages [[multi-core processor]]s and results in higher [[Central processing unit|CPU]] utilization.
|