List<T>.ICollection.IsSynchronized List<T>.ICollection.IsSynchronized List<T>.ICollection.IsSynchronized Property


取得值,這個值表示對 ICollection 的存取是否同步 (安全執行緒)。Gets a value indicating whether access to the ICollection is synchronized (thread safe).

property bool System::Collections::ICollection::IsSynchronized { bool get(); };
bool System.Collections.ICollection.IsSynchronized { get; }
 ReadOnly Property IsSynchronized As Boolean Implements ICollection.IsSynchronized


如果 true 的存取為同步 (安全執行緒),則為 ICollection,否則為 falsetrue if access to the ICollection is synchronized (thread safe); otherwise, false. List<T> 的預設實作中,這個屬性永遠會傳回 falseIn the default implementation of List<T>, this property always returns false.



System.Collections.Generic 命名空間中集合的預設實作未同步處理。Default implementations of collections in the System.Collections.Generic namespace are not synchronized.

透過集合進行列舉在本質上並非安全執行緒程序。Enumerating through a collection is intrinsically not a thread-safe procedure. 在具有寫入存取權的列舉會爭用的罕見情況下, 您可以在整個列舉期間鎖定集合。In the rare case where enumeration contends with write accesses, you can lock the collection during the entire enumeration. 若要讓多重執行緒能夠存取集合以便進行讀取和寫入,您必須實作自己的同步處理。To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization.

SyncRoot傳回可用來同步存取的ICollection物件。SyncRoot returns an object that can be used to synchronize access to the ICollection. 只有在所有線程在存取集合之前鎖定此物件時, 同步處理才會生效。Synchronization is effective only if all threads lock this object before accessing the collection.

擷取這個屬性的值是一種 O(1) 運算。Retrieving the value of this property is an O(1) operation.