「ダブル・チェック・ロッキング」の版間の差分

imported>Administrator
imported>Administrator
編集の要約なし
44行目: 44行目:


=== C# (Lazy) ===
=== C# (Lazy) ===
[[.NET Framework 4.0]]では、標準でLazy<T>クラスが用意されており、それを使うことでよりシンプルにダブル・チェック・ロッキングを記述できるようになった<ref>{{cite  
[[.NET Framework 4.0]]では、標準でLazy<T>クラスが用意されており、それを使うことでよりシンプルにダブル・チェック・ロッキングを記述できるようになった<!--<ref>{{cite  
  |title=C# 4.0 in a Nutshell
  |title=C# 4.0 in a Nutshell
  |last=Albahari
  |last=Albahari
54行目: 54行目:
  |chapterurl=http://www.albahari.com/threading/part3.aspx#_LazyT
  |chapterurl=http://www.albahari.com/threading/part3.aspx#_LazyT
  |quote=<code>Lazy&lt;T&gt;</code> actually implements […] double-checked locking. Double-checked locking performs an additional volatile read to avoid the cost of obtaining a lock if the object is already initialized.
  |quote=<code>Lazy&lt;T&gt;</code> actually implements […] double-checked locking. Double-checked locking performs an additional volatile read to avoid the cost of obtaining a lock if the object is already initialized.
}}</ref>。
}}</ref>-->。
この記述方法は[[C Sharp|C#]]に依存した機能も特に使われておらず、[[.NET Framework]]系の様々な[[プログラミング言語]]へも特に悩むことなく移植・実装可能であると思われる。
この記述方法は[[C Sharp|C#]]に依存した機能も特に使われておらず、[[.NET Framework]]系の様々な[[プログラミング言語]]へも特に悩むことなく移植・実装可能であると思われる。
<source lang="csharp">
<source lang="csharp">