using PENet;
using PEProtocol;
using System.Collections.Generic;
class NetSvc
{
private static NetSvc instance = null;
public static NetSvc Instance
{
get
{
if (instance == null)
{
instance = new NetSvc();
}
return instance;
}
}
public static readonly string obj = "lock";//这个是干什么用的?
/// <summary>
/// 接受消息队列
/// </summary>
private Queue<GameMsg> msgPackQue = new Queue<GameMsg>();
public void Init()
{
PESocket<ServerSession, GameMsg> server = new PESocket<ServerSession, GameMsg>();
server.StartAsServer(SrvCfg.srvIP, SrvCfg.srvPort);
PECommon.Log("NetSvc Init Done.");
}
public void AddMsgQue(GameMsg msg)
{
lock (obj)
{
msgPackQue.Enqueue(msg);
}
}
}
线程锁我知道,为什么不是锁队列msgPackQue,锁一个只读字符串是什么操作?