今天自己写一个简单的模拟线程池,遇到这样一个Object synchronization method was called from an unsynchronized block of code,解决不了,谁给解释一下?
下面是我的主要思路:class concreteTask : task
    {
        public override void begin() //开始运行线程
        {
            try
            {
                threadmutex.ReleaseMutex();
            }
            catch (Exception e)
            {
                Console.WriteLine("线程调度失败!{0}", e.Message);
            }
        }
         public override void run()
        {
            while (true)
            {
                threadmutex.WaitOne();   //等待新的调度进入
                stat = true;
                {
                    //TODO:在此提供具体的任务处理
                }
                stat = false;
               // threadmutex.ReleaseMutex();
            }
        }
}
在线程池中我只要不断调用begin()就能取得一个线程执行一个任务但在 threadmutex.ReleaseMutex()这一句总是出现 Object synchronization method was called from an unsynchronized block of code