static void main(string[] args)
        {
            //写日志
            //使用线程池
            for (int i = 0; i < 1000; i++)
            {
                threadpool.queueuserworkitem(new waitcallback(receivemessage), i);
            }
            
            console.readkey();
        }

        private static void receivemessage(object index)
        {
            thread.sleep(100);
            int b = 0;
            try
            {
                if (index.tostring() == "50")
                {
                    console.writeline(100 / b);
                }
                else
                {
                    console.writeline(index.tostring());
                }
            }
            catch (exception)
            {
                console.writeline(index+":出错");
            }
           
           
        }

以上是测试代码,结论如下:

1.线程池中的异常不做处理:会导致整个程序的闪退

2.针对异常代码添加异常处理机制:不影响其他线程的执行