Why java.util.concurrent.atomic.AtomicBoolean is internally implemented with int?

atomic, concurrency, java, java.util.concurrent, multithreading

Solution

AFAIK, `int` is the smallest type CAS operations can be implemented across different machine types.

Note: as object allocations are 8 byte aligned, using a smaller type wouldn't save any memory.

Problem

AtomicBoolean stores its value in: ``` private volatile int value; ``` Then, for example, extracting its value is done like this: ``` public final boolean get() { return value != 0; } ``` What is the reason behind it? Why `boolean` was not used?

Original source