Skip to content

Instantly share code, notes, and snippets.

@takekazuomi
Created February 27, 2012 05:52
Show Gist options
  • Save takekazuomi/1921769 to your computer and use it in GitHub Desktop.
Save takekazuomi/1921769 to your computer and use it in GitHub Desktop.
Double-checked locking
private static FileSystemWatcherPool sInstance;
private static object sLock = new object();
private FileSystemWatcherPool() {
this.cleanupTimer = new Timer(InvalidateWatcherList, null, OneMinute, OneMinute);
}
public static FileSystemWatcherPool Instance {
get {
if (sInstance == null) {
lock (sLock) {
if (sInstance == null) {
sInstance = new FileSystemWatcherPool();
}
}
}
return sInstance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment