Is there any difference in meaning of AtomicIntegerArray
and AtomicInteger[]
?
And which one is faster to use?
(only thing that I noticed is that first is taking much less space, but that means that each recheck is checking boundaries of array, so that would make it slower?)
Edit: In a scenario where array is pre-initialized.
AtomicInteger[]
will require an object per element. AtomicIntegerArray
just requires the AtomicIntegerArray
object and an array object. So use the latter if possible.
The cost of bounds checking is quite small even for normal arrays. What might be significant is that access to data in the same cache line from multiple processors can cause significant performance issues. Therefore separate objects, or deliberately avoiding close elements of an array, can help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With