读写同步:AutoResetEvent:ReadThread After WriteThread
来源:互联网 发布:java等于号 编辑:程序博客网 时间:2024/06/05 05:00
using System;
using System.Threading;
namespace AutoResetEvent_Examples
{
class MyMainClass
{
const int numIterations = 10;
static AutoResetEvent myResetEvent = new AutoResetEvent(false);
static int number;
static void Main()
{
Thread myReaderThread = new Thread(new ThreadStart(MyReadThreadProc));
myReaderThread.Name = "ReaderThread";
myReaderThread.Start();
for (int i = 1; i <= numIterations; i++)
{
Console.WriteLine("Writer thread writing value: {0}", i);
number = i;
myResetEvent.Set();
Thread.Sleep(0);
}
myReaderThread.Abort();
Console.ReadKey();
}
static void MyReadThreadProc()
{
while (true)
{
myResetEvent.WaitOne();
Console.WriteLine("{0} reading value: {1}", Thread.CurrentThread.Name, number);
}
}
}
}
- 读写同步:AutoResetEvent:ReadThread After WriteThread
- C#读写者线程(用AutoResetEvent实现同步)
- C#读写者线程(用AutoResetEvent实现同步)
- C#读写者线程(用AutoResetEvent实现同步)
- 线程同步 - EventWaitHandle & AutoResetEvent & ManualResetEvent
- ManualResetEvent,AutoResetEvent类线程同步
- AutoResetEvent和ManualResetEvent 线程同步
- 线程同步:ManualResetEvent和AutoResetEvent
- C#多线程同步(四)【AutoResetEvent】
- AutoResetEvent
- AutoResetEvent
- AutoResetEvent
- AutoResetEvent
- AutoResetEvent
- AutoResetEvent
- AutoResetEvent
- AutoResetEvent
- 线程同步之AutoResetEvent的使用
- TCP协议深入理解
- 关于Tom网站!
- 斗地主—游戏规则
- google日历的农历循环提醒
- eclipse 中 r6025 pure virtual function call 错误的解决方法
- 读写同步:AutoResetEvent:ReadThread After WriteThread
- MooTools 1.2.4 IT民工学习笔记一 (Native)
- XP IIS下配置.net的问题总结与简单解决方法
- 推荐博客URL
- event.keycode值大全
- 为了记下岁月的痕迹
- bulk insert 导入文件为时间变量
- Java语言如何访问不同字符集的Oracle数据
- 几种常用JSON库的性能测试。