Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why there is no AtomicBooleanArray datatype in Java?

I have noticed that there is NO AtomicBooleanArray datatype in Java similar to the AtomicIntegerArray. Although I can use AtomicBoolean[] for my current needs, I was curious to get an understanding as to why AtomicBooleanArray is NOT part of the library.

Any thoughts in this would be much appreciated.

Thanks

like image 906
JProgrammer Avatar asked Oct 20 '22 22:10

JProgrammer


1 Answers

AtomicBoolean actually wraps a int which is set to 0 or 1 for false or true. This is because it uses compareAndSwap methods which are int based, and not smaller.

You could implement an AtmoicBooleanArray, but not cleanly which is perhaps why it is not there. i.e. the JVM doesn't support atomic boolean operations because the CPUs like x64 and ARM don' support it.

like image 143
Peter Lawrey Avatar answered Oct 24 '22 13:10

Peter Lawrey