Integer VS AtomicInteger VS MutableInteger
Posted 风来了
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Integer VS AtomicInteger VS MutableInteger相关的知识,希望对你有一定的参考价值。
- 由于Integer是不可变的,每个循环增加key的value时会创建一个新的对象
- 每次value+1时不需要重新创建Integer对象
Integer, Boolean 等 is immutable, you can only change the reference, but you can‘t change the object itself. 固有MutableInteger
class Holder<T> { public T value; }
The choice of these two types should not depend on the performance. The main choice for AtomicInteger
is if
you want to achieve thread safety with the operations on the integer. However the performace difference might
strongly depend on the choosen operating system, as the detailed implementation of atomic operations depend
on the operating system.
以上是关于Integer VS AtomicInteger VS MutableInteger的主要内容,如果未能解决你的问题,请参考以下文章