PacketHandler(); //包含了所有执行程序
PacketHandler 最终输出要调整的url,里面进行了N多判断,发现用2个进程测试,程序奔溃。
private static object asyncLock_1 = new object();
Thread thread1 = new Thread(new ThreadStart(PostTest1));
Thread thread2 = new Thread(new ThreadStart(PostTest1));
thread1.Start();
thread2.Start();
thread1.Join();
thread1.Join();
1 protected void PostTest1() 2 { 3 lock (asyncLock4) 4 { 5 //遍历用户表进行测试 6 DataTable dt = SqlHelper.GetDataTable(CommandType.Text, txtSql.Text, null); 7 if (dt != null) 8 { 9 for (int i = 0; i < dt.Rows.Count; i++) 10 { 11 PacketHandlert(int.Parse(txt1.Text.Trim()), int.Parse(dt.Rows[i]["Uid"].ToString()), int.Parse(dt.Rows[i]["groupId"].ToString())); 12 } 13 } 14 } 15 }
处理并发无法就是锁,原子操作,单队列
建议先注释PacketHandlert的调用,看会不会崩溃?