A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/c-sharp/c-sharp-check-if-arraylist-is-synchronized-thread-safe/ below:

C# | Check if ArrayList is Synchronized (thread safe)

C# | Check if ArrayList is Synchronized (thread safe)

Last Updated : 11 Jul, 2025

ArrayList.IsSynchronized Property

is used to get a value which indicate whether access to the

ArrayList

is synchronized (thread safe).

Syntax:
public virtual bool IsSynchronized { get; }
Return Value:

This property returns the

true

if access to the ArrayList is synchronized (thread safe) otherwise it returns

false

. The default is

false

. Below programs illustrate the use of above-discussed property:

Example 1: CSharp
// C# code to check if ArrayList
// Is Synchronized or not
using System;
using System.Collections;

class GFG {

    // Driver code
    public static void Main()
    {

        // Creating an ArrayList
        ArrayList myList = new ArrayList();

        // Adding elements to ArrayList
        myList.Add("A");
        myList.Add("B");
        myList.Add("C");
        myList.Add("D");
        myList.Add("E");
        myList.Add("F");

        // Creates a synchronized
        // wrapper around the ArrayList
        ArrayList smyList = ArrayList.Synchronized(myList);

        // Displays the synchronization
        // status of both ArrayList
        Console.WriteLine("myList is {0}.", myList.IsSynchronized ?
                               "Synchronized" : "Not Synchronized");

        Console.WriteLine("smyList is {0}.", smyList.IsSynchronized ? 
                                "Synchronized" : "Not Synchronized");
    }
}
Output:
myList is Not Synchronized.
smyList is Synchronized.
Example 2: CSharp
// C# code to check if ArrayList
// Is Synchronized or not
using System;
using System.Collections;

class GFG {

    // Driver code
    public static void Main()
    {

        // Creating an ArrayList
        ArrayList myList = new ArrayList();

        // Adding elements to ArrayList
        myList.Add(1);
        myList.Add(2);
        myList.Add(3);
        myList.Add(4);
        myList.Add(5);
        myList.Add(5);

        // the default is false for 
        // IsSynchronized property
        Console.WriteLine(myList.IsSynchronized);
    }
}
Note: Reference:

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4