码迷,mamicode.com
首页 > 其他好文 > 详细

Integer VS AtomicInteger VS MutableInteger

时间:2017-07-29 21:30:55      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:一个   safe   detail   public   ace   mmu   title   strong   can   

  • 由于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.

 

 

Java高效计数器

Integer VS AtomicInteger VS MutableInteger

标签:一个   safe   detail   public   ace   mmu   title   strong   can   

原文地址:http://www.cnblogs.com/yuyutianxia/p/7257427.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!