久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

List.iterator() 是線程安全的嗎?

Is List.iterator() thread-safe?(List.iterator() 是線程安全的嗎?)
本文介紹了List.iterator() 是線程安全的嗎?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

在 Java 中:List.iterator() 是線程安全的,即返回的迭代器是否反映了列表在任何時候的當前狀態(tài),或者只是列表在其時的狀態(tài)創(chuàng)作?

In Java: Is List.iterator() thread-safe, i.e. does the returned iterator reflect the current state of the list at any time or just the state of the list at the time of its creation?

推薦答案

List.iterator() 的行為未定義或與不同的 List 實現(xiàn)一致.

The behaviour of List.iterator() is not defined or consistent with different List implementations.

對于 ArrayList、LinkedList,如果在迭代列表時修改了列表,則可能會得到 ConcurrentModificationException.(不能保證)避免此問題的方法是使用 synchronizedList() 并在迭代列表時鎖定列表.

For ArrayList, LinkedList, you can get a ConcurrentModificationException if the list is modified when you are iterating over it. (This is not guaranteed) The way to avoid this issue is to use a synchronizedList() and lock the list while iterating over it.

對于 Vector,集合是同步的,但迭代器不是線程安全的.

For Vector, the collection is synchronized, but the iterator is not thread safe.

對于 CopyOnWriteArrayList,您在調用 iterator() 時會獲得列表中元素的快照,此迭代器是線程安全的,您不需要使用任何鎖定.注意:元素的內容可以改變.

For CopyOnWriteArrayList, you get a snapshot of the elements in the list at the time you call iterator(), This iterator is thread safe, and you don't need to use any locking. Note: the contents of the elements can change.

這篇關于List.iterator() 是線程安全的嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

Java Remove Duplicates from an Array?(Java從數(shù)組中刪除重復項?)
How to fix Invocation failed Unexpected Response from Server: Unauthorized in Android studio(如何修復調用失敗來自服務器的意外響應:在 Android 工作室中未經(jīng)授權)
AES encryption, got extra trash characters in decrypted file(AES 加密,解密文件中有多余的垃圾字符)
AES Error: Given final block not properly padded(AES 錯誤:給定的最終塊未正確填充)
Detecting incorrect key using AES/GCM in JAVA(在 JAVA 中使用 AES/GCM 檢測不正確的密鑰)
AES-256-CBC in Java(Java 中的 AES-256-CBC)
主站蜘蛛池模板: 国产精品美女一区二区三区 | 欧美日韩精品久久久免费观看 | 成人h片在线观看 | 久久久久久综合 | 久草新视频 | 国产精品成人一区二区三区 | 国产精品久久久久久吹潮 | 国内久久 | 一区在线观看 | 综合久久久 | 久久成人一区 | 欧美 日本 国产 | 日本一本在线 | 亚洲一二三区在线观看 | 欧州一区二区 | 久久精品91久久久久久再现 | 亚洲福利| 欧美jizzhd精品欧美巨大免费 | 日韩午夜 | 国产精品123区 | 在线观看亚洲欧美 | 日韩成人在线观看 | 国产精品精品久久久久久 | 精品国产欧美 | 午夜精品久久久久久不卡欧美一级 | 黄色日本片| 久久国产精彩视频 | 综合久 | 亚洲精品久久久 | 欧美日韩在线一区 | 欧美日韩高清 | 亚洲精品在线观看网站 | 欧美精品一区二区三 | 午夜电影网址 | 91精品国产综合久久香蕉麻豆 | 欧美一级毛片在线播放 | 日韩免费毛片视频 | 午夜免费视频 | 九九免费在线视频 | 国产精品久久久99 | 午夜视频在线 |