This method(comes under
System.Collections namespace) is used to get a value indicating whether access to the Stack is synchronized (thread safe) or not. To guarantee the thread safety of the Stack, all operations must be done through the wrapper returned by the
Synchronized method. Also, retrieving the value of this property is an
O(1) operation.
Syntax:
public virtual bool IsSynchronized { get; }
Return Value: This property returns
true, if access to the Stack is synchronized (thread safe) otherwise it returns
false. The default is
false.
Below programs illustrate the use of above-discussed property:
Example 1:
Output:
myStack is Not Synchronized.
ss is Synchronized.
Example 2: