public static int num;
public static int time;
public static int finshedCount = 0;
//控制台入口函数
static void Main(string[] args)
{
//并发用户数
Console.WriteLine("-------------------------测试程序开始-------------------------");
Console.Write("请输入并发用户数:");
num = Int32.Parse(Console.ReadLine());
num = num == 0 ? 1000 : num;
//并发时间
Console.Write("请输入并发时间:");
time = Int32.Parse(Console.ReadLine());
time = time == 0 ? 30 * 60 : time;
//获取G3DRest服务请求地址
restUrl = CommHelper.getRestUrl();
for (int i = 0; i < num; i++)
{
Thread thread = new Thread((() =>
{
{
// 并发执行函数
getCovering();
}
}));
thread.Start();
}
//并发结束后,执行函数
while (true) {
Thread.Sleep(3000);
if (finshedCount == num) {
writeLog();
break;
}
}
Console.WriteLine("-------------------------测试程序结束-------------------------");
Console.ReadKey();
}
// 并发执行函数
public static void getCovering()
{
/……/finshedCount ++;
//并发结束后,执行函数}
public static writeLog()
{
/……/
}