ICollection.SyncRoot属性

作者:追风剑情 发布于:2015-3-28 15:45 分类:C#

ICollection myCollection = someCollection;
//锁定集合,保证线程安全
lock ( myCollection.SyncRoot ) {
      foreach ( object item in myCollection ) {
            // Insert your code here.
      }
}

标签: C#

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号