AtomicInteger类型比较
时间: 2023-10-19 17:26:26 浏览: 98
AtomicInteger类型比较是通过调用equals()方法进行的。不同于Integer类型的比较,AtomicInteger类型的equals()方法比较的是引用地址而不是值本身。所以,即使两个AtomicInteger对象的值相等,它们的equals()方法也会返回false。例如,对于两个AtomicInteger对象atomicInteger1和atomicInteger2,即使它们的值都是1,但atomicInteger1.equals(atomicInteger2)的结果将是false。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [AtomicInteger原子类、判空工具类、比较时间大小](https://blog.csdn.net/qq453660983/article/details/125279288)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [java并发之AtomicInteger源码分析](https://download.csdn.net/download/weixin_38606076/12749202)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [切忌用equal比较AtomicInteger类型](https://blog.csdn.net/xu962336414/article/details/101688721)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文