乒乓球锁:Lock an Object:Switch Different Functions
来源:互联网 发布:linux下载jdk1.8 命令 编辑:程序博客网 时间:2024/05/21 16:48
using System.Threading;
public class Program
{
static object ball = new object();
public static void Main()
{
Thread threadPing = new Thread(ThreadPingProc);
Thread threadPong = new Thread(ThreadPongProc);
threadPing.Start(); threadPong.Start();
}
static void ThreadPongProc()
{
System.Console.WriteLine("ThreadPong: Hello!");
lock (ball)
for (int i = 0; i < 5; i++)
{
System.Console.WriteLine("ThreadPong: Pong ");
Monitor.Pulse(ball);
Monitor.Wait(ball);
}
System.Console.WriteLine("ThreadPong: Bye!");
}
static void ThreadPingProc()
{
System.Console.WriteLine("ThreadPing: Hello!");
lock (ball)
for (int i = 0; i < 5; i++)
{
System.Console.WriteLine("ThreadPing: Ping ");
Monitor.Pulse(ball);
Monitor.Wait(ball);
}
System.Console.WriteLine("ThreadPing: Bye!");
}
}
- 乒乓球锁:Lock an Object:Switch Different Functions
- A pointer to an object & A pointer one past the end of a different object
- 锁对象(lock object)
- Lock Object 锁表机制
- sap lock object 锁机制
- Lock Object
- Lock object
- SAP锁对象(lock object)
- SAP锁对象(lock object)
- LOCK instruction and InterLocked* functions
- 乒乓球
- 乒乓球
- 乒乓球
- 乒乓球
- 乒乓球
- 乒乓球
- 乒乓球
- 乒乓球
- 读Excel:Reading excel in a ListBox
- IIS使用指南之一 :IIS 6 新特性
- Master Page 页面请求的次序
- Windows消息调度机制
- 精解PSI-SI
- 乒乓球锁:Lock an Object:Switch Different Functions
- 反编译学习笔记——编译过程
- shell 中一些特殊符号的含义简介
- Linux下MySQL5.1的安装
- 哲学家问题之死锁:A Difficult Philosopher Problem
- Sql Server 2005的1433端口打开和进行远程连接
- Modultils工具源码分析之insmod篇 (7)
- 分享:Digital Geometry Processing 的链接
- MPEG-2视频编码技术漫谈