多線程:多個線程同步執行,完成一件事或者多件事。工做方式:不一樣線程根據執行順序共享CPU中的時間片斷資源來處理程序。安全
線程等待:線程根據執行優先級訪問資源,在釋放某個資源以前,其餘線程只能排隊等待資源的釋放。多線程
線程同步:也就是多個線程之間的執行順序關係。spa
如何實現多線程跨線程訪問安全?上一段簡單的代碼,仍是一個單例模式咯?線程
1 public class DataInfo 2 { 3 private static DataInfo _current; 4 private static readonly object _synLock = new object();//線程鎖 5 public static DataInfo Current 6 { 7 get { 8 if (_current == null) 9 { 10 lock (_synLock) 11 { 12 if (_current == null) 13 { 14 _current = new DataInfo(); 15 } 16 } 17 } 18 return _current; 19 } 20 } 21 }
--2011 to write notescode