线程互斥 和线程锁的解决

static Mutex myMutex = new Mutex();
 
 
 static public bool writeLine(string instr,string fileName)
{
  myMutex.WaitOne();
 
  .......[做文件读写就行了]
 
  myMutex.ReleaseMutex();
}

  

 private System.Object lockThis = new System.Object();
 lock (lockThis)
        {
            // Access thread-sensitive resources.
        }

  

posted @ 2013-05-08 15:32  shineme  阅读(255)  评论(0编辑  收藏  举报