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

  • :aspxer  Դ:csdn  :2007-7-6 2:51:38  ؼ:
  • 第11楼. 由 calen 于 2007-6-30 8:49:20 发表

    up

    第12楼. 由 cnming 于 2007-6-30 9:02:55 发表

    using System;

    using System.Threading;

    using System.Collections;

    namespace OracleTest

    {

    class MonitorSample

    {

    const int MAX_LOOP_TIME = 1000;

    Queue m_smplQueue;

    public MonitorSample()

    {

    m_smplQueue = new Queue();

    }

    public void FirstThread()

    {

    int counter = 0;

    lock(m_smplQueue)

    {

    while(counter < MAX_LOOP_TIME)

    {

    //Wait, if the queue is busy.

    Monitor.Wait(m_smplQueue);

    //Push one element.

    m_smplQueue.Enqueue(counter);

    //Release the waiting thread.

    Monitor.Pulse(m_smplQueue);

    counter++;

    }

    }

    }

    public void SecondThread()

    {

    lock(m_smplQueue)

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