lock (typeof(CacheUtils)) {...}
I've since learned this is a bad idea (not a Really Bad Idea but bad enough). After reading articles like Don't Lock Type Objects and Safe Thread Synchronization I've realized the errors of my ways. The better pattern is to use an internal lightweight objects. For example:
private static readonly object locker = new object(); lock (locker) {...}
No comments:
Post a Comment