C# Queue IsSynchronized

Description

Queue IsSynchronized gets a value indicating whether access to the Queue is synchronized (thread safe).

Syntax

Queue.IsSynchronized has the following syntax.


public virtual bool IsSynchronized { get; }

Example

The following example shows how to synchronize a Queue, determine if a Queue is synchronized, and use a synchronized Queue.


using System;//from   w  w w.j a v a 2  s.com
using System.Collections;
public class SamplesQueue  {

   public static void Main()  {
      Queue myQ = new Queue();
      myQ.Enqueue( "A" );
      myQ.Enqueue( "B" );
      myQ.Enqueue( "C" );
      myQ.Enqueue( "D" );

      Queue mySyncdQ = Queue.Synchronized( myQ );

      Console.WriteLine(myQ.IsSynchronized);
      Console.WriteLine(mySyncdQ.IsSynchronized);
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Collections »




ArrayList
BitArray
Comparer
Hashtable
Queue
SortedList
Stack