我爱Aspx >> Asp.Net >> 线程如何挂起和继续?要使用最新的模式,也就是System.Threading.Monitor第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)
Ҷƪл˵?
学习哪门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]