Array.IsSynchronized Property is used to get a value which indicates whether access to the Array is synchronized (thread-safe) or not.
Syntax:
public bool IsSynchronized { get; }
Property Value: This property always returns false for all arrays.
Below programs illustrate the use of above-discussed property:
Example 1:
// C# program to illustrate // IsSynchronized Property of // Array class using System; namespace geeksforgeeks { class GFG { // Main Method public static void Main() { // The array with dimensions // specified 4 row and 2 column. int[, ] arr = new int[4, 2] {{1, 2 }, {3, 4}, {5, 6 }, {7, 8}}; // Here we check whether the // array is synchronized (thread safe) // or not Console.WriteLine("Result: " + arr.IsSynchronized); } } } |
chevron_right
filter_none
Output:
Result: False
Example 2:
// C# program to illustrate // IsSynchronized Property of // Array class using System; namespace geeksforgeeks { class GFG { // Main Method public static void Main() { // declares an 1D Array of string. string[] topic; // allocating null to array topic = new string[] { null }; // Here we check whether the // array is synchronized (thread safe) // or not Console.WriteLine("Result: " + topic.IsSynchronized); } } } |
chevron_right
filter_none
Output:
Result: False
Note:
- Array implements the IsSynchronized property because it is needed by the System.Collections.ICollection interface.
- Classes which uses the arrays can also implement their own synchronization using the SyncRoot property.
- Enumerating through a collection is not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.
- Retrieving the value of this property is an O(1) operation.
Reference:
Recommended Posts:
- C# | Check if the BitArray is synchronized (thread safe)
- C# | Check if ArrayList is Synchronized (thread safe)
- C# | Check if StringDictionary is synchronized (thread safe)
- C# | Check if StringCollection is synchronized (thread safe)
- C# | Check if ListDictionary is synchronized (thread safe)
- C# | Check if Hashtable is synchronized (thread safe)
- C# | Check if HybridDictionary is Synchronized (thread safe)
- C# | Creating a synchronized (thread-safe) wrapper for the ArrayList
- C# | Creating a synchronized (thread-safe) wrapper for the Hashtable
- C# | Creating a synchronized (thread-safe) wrapper for a SortedList object
- C# | Check if a thread belongs to managed thread pool or not
- How to check whether a thread is a background thread or not in C#
- C# | Check if a SortedList object is synchronized
- How to check whether a thread is alive or not in C#
- C# | How to check current state of a thread
- Naming a thread and fetching name of current thread in C#
- Queue.Synchronized() Method in C#
- Stack.Synchronized() Method in C#
- Thread Class in C#
- How to Terminate a Thread in C#
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

