我爱Aspx >> Asp.Net >> 线程如何挂起和继续?要使用最新的模式,也就是System.Threading.Monitor{
//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));
Ҷƪл˵?
学习哪门Web开发语言好?[07-06]
窗口中的控件放不下了怎么办?[07-06]
超级简单的问题~遍历文件[07-06]
字符串怎么转换成日期?[07-06]
关于反射的效率问题[07-06]
初学三层结构问题[07-06]
窗口刷新闪烁问题[07-06]
类似这样的XML该如何读取?如何形..[07-06]
请问:如何用C#生成一个完整的xm..[07-06]
在 System.InvalidOperationExce..[07-06]