首页 新闻 会员 周边

怎么实现用多线程模仿多用户访问同一个方法?

0
悬赏园豆:10 [已解决问题] 解决于 2008-10-14 15:55

各位朋友好,我想用多线程来模仿多用户调用同一个方法测试下其性能,有做过类似需求的朋友给我点意见,有DEMO做好,嘿嘿,非常感谢.

亮 剑的主页 亮 剑 | 初学一级 | 园豆:40
提问于:2008-09-30 08:50
< >
分享
最佳答案
0

Code
public void Main() {
Thread[] threads
= new Thread[100];
for(int i = 0; i < threads.Length; i++) {
threads[i]
= new Thread(new ThreadStart(TestThread));
threads[i].Start();
}
}

private void TestThread() {
//Invoke mothods tested here
//..
}
大侠,是不是我的做法太“幼稚”了?这样做有哪些不妥的地方?

陛下 | 老鸟四级 |园豆:3938 | 2008-09-30 11:03
其他回答(1)
0

看不出有什么不妥。

Todd Wei | 园豆:170 (初学一级) | 2008-10-03 20:13
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册