C# 多线程循环执行 计数器 循环创建10个线程,每个线程调用一个方法,然后每个线程再相隔10秒一直循环执行,并统计每个线程执行次数。请问各位大侠,这个代码怎么实现? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Thread[] tr = new Thread[10];Count[] trCount = new Count[10];class Count{ private int _count = 0; public int Count { get { return _count; } } public void Count() { while(true) { _cout++; Thread.Sleep(10000); } }}for(int i=0;i<tr.length;i++){ trCount[i] = new Count(); tr[i] = new Thread(new ThreadStart(trCount[i].Count)); tr[i].Start(); } 1楼的应该可以。你要返回值,只要调用tr[i].Count就可以啊。 关于如果预览图片的问题 winform连接sqlite的代码 大家帮忙看看这个ArrayList问题。(三个foreach中的输出语句为什么不输出) 求教ref以及指针问题 我想写个sql语句的parser来分析sql,哪位有相关的资料给一点。 让列表框1中所有项到列表框2中 CSharp中接口问题 system.invalidcastexception:对象必须实现Iconvertible. 调用外部模块(VFP)的问题 C/S程序中如何在广域网环境访问远程数据库? 用MYSQL 这段SQL语句该怎么下手呢? Winform中GID+绘图问题。。
Count[] trCount = new Count[10];class Count
{
private int _count = 0;
public int Count
{
get { return _count; }
}
public void Count()
{
while(true)
{
_cout++;
Thread.Sleep(10000);
}
}
}for(int i=0;i<tr.length;i++)
{
trCount[i] = new Count();
tr[i] = new Thread(new ThreadStart(trCount[i].Count));
tr[i].Start();
}