I was looking for a template that could provide both a thread-safe and an unsafe version of the same class. The technical aspects of this are pretty obvious. I think I was hoping to find naming conventions and access, etc ....
Therefore, I find this template throughout the "Systems.Collections" namespace:
public class WhatEv
{
private class SyncWhatEv : WhatEv
{
}
public virtual bool IsSynchronized
{
get { return false; }
}
public static WhatEv Synchronized(WhatEv whatEv)
{
return new SyncWhatEv(whatEv);
}
}
There are a number of classes that implement this: HashTable, Queue, ArrayList, Stack, etc. I understand inheritance. But why make it a private, nested class and make the user jump through the hoop to get to it? Are there any advantages to this?
TBone source
share