for (int i = 0; i < x; i++) { mythread[i] = new Thread(new ThreadStart(t.Email_Thread)); mythread[i].Start(); } 如果x太大会同时开启很多个线程。怎么才能有效控制多线程的合理控制(比如固定开启线程个数),我看了线程池的相关资料,没明白什么意思。~_~
public class MutexTest
...{
private static int poolFlag = 0 ;//标记
private const int amountThread = 10 ;//线程总量
private const int maxThread = 3 ;//可执行线程最大数量
private static Mutex muxConsole = new Mutex() ;
public static void Main()
...{
for ( int i = 0 ; i < amountThread ; i ++ )
...{
// 创建指定数量的线程
// 是线程调用Run方法
// 启动线程
Thread trd = new Thread( new ThreadStart( Run ) ) ;
trd.Name = "线程" + i ;
trd.Start() ;
}
}