感谢RonoTian的提议
我在家写了相应的代码:
class BackThread//后台线程调用类
{
List<Thread> list = new List<Thread>();
public void ThreadsWork()
{
for (int i = 0; i < 3; i++)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(xx));
}
}
private void xx(object obj)
{
//Thread.CurrentThread;
list.Add(Thread.CurrentThread);
DataTable table = new DataTable();
table.Columns.Add("id",typeof(int));
table.Columns.Add("name",typeof(string));
for (int i = 0; i < 10000000; i++)
{
DataRow row = table.NewRow();
row[0] = i;
row[1] = "wu" + i.ToString();
}
}
public void Close()
{
foreach (Thread thread in list)
{
thread.Abort();
}
}
}