How do you solve the max value problem when using an integer counter, that looks like
counter = counter + 1;
When this reaches the max value, how do you know this happened? Do you add another counter for this counting how often this happened?
My question concerns about java.
For a fast saturated
intincrement (one that stops when it gets toMAX_VALUE), I guess you could write:Or
Or in the interests of fun, for
AtomicInteger, I think: