• λ我爱Aspx >> Asp.Net >> 线程如何挂起和继续?要使用最新的模式,也就是System.Threading.Monitor
  • 线程如何挂起和继续?要使用最新的模式,也就是System.Threading.Monitor

  • :aspxer  Դ:csdn  :2007-7-6 2:51:38  ؼ:
  • {

    //Release the waiting thread.

    Monitor.Pulse(m_smplQueue);

    //Wait in the loop, while the queue is busy.

    //Exit on the time-out when the first thread stops.

    while(Monitor.Wait(m_smplQueue,1000))

    {

    //Pop the first element.

    int counter = (int)m_smplQueue.Dequeue();

    //Print the first element.

    Console.WriteLine(counter.ToString());

    //Release the waiting thread.

    Monitor.Pulse(m_smplQueue);

    }

    }

    }

    //Return the number of queue elements.

    public int GetQueueCount()

    {

    return m_smplQueue.Count;

    }

    static void Main(string[] args)

    {

    //Create the MonitorSample object.

    MonitorSample test = new MonitorSample();

    //Create the first thread.

    Thread tFirst = new Thread(new ThreadStart(test.FirstThread));

    Ҷƪл˵?
  • һƪcheckbox入门问题,麻烦各位
    һƪ学习哪门Web开发语言好?