using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;namespace ConsoleApplication1
{
class Program
{
Thread th; void bbbbbbb()
{
th = new Thread(thStart);
th.Start();
} void thStart()
{
Thread[] ths = new Thread[5];
System.Threading.ThreadStart startThread = new System.Threading.ThreadStart(thsStart);
for (int t = 0; t < 5; t++)
{
ths[t] = new Thread(thsStart);
ths[t].Name = t.ToString();
ths[t].Start();
}
} void thsStart()
{
for (int i = 0; i < 10; i++)
{
if (i == 5)
{
th.Abort();
}
Console.WriteLine(i.ToString() + "\t" + Thread.CurrentThread.Name);
}
}
static void Main(string[] args)
{
Program p = new Program();
p.bbbbbbb();
}
}
}
在 main() 方法内启动呢进程 th ...在 th 内启动呢进程 ths....如何在 main() 的进程内关闭正在执行的 th 和 ths 进程呢.我使用呢..th.Abort(); 可是子进程 ths 还在执行
using System.Collections.Generic;
using System.Text;
using System.Threading;namespace ConsoleApplication1
{
class Program
{
Thread th; void bbbbbbb()
{
th = new Thread(thStart);
th.Start();
} void thStart()
{
Thread[] ths = new Thread[5];
System.Threading.ThreadStart startThread = new System.Threading.ThreadStart(thsStart);
for (int t = 0; t < 5; t++)
{
ths[t] = new Thread(thsStart);
ths[t].Name = t.ToString();
ths[t].Start();
}
} void thsStart()
{
for (int i = 0; i < 10; i++)
{
if (i == 5)
{
th.Abort();
}
Console.WriteLine(i.ToString() + "\t" + Thread.CurrentThread.Name);
}
}
static void Main(string[] args)
{
Program p = new Program();
p.bbbbbbb();
}
}
}
在 main() 方法内启动呢进程 th ...在 th 内启动呢进程 ths....如何在 main() 的进程内关闭正在执行的 th 和 ths 进程呢.我使用呢..th.Abort(); 可是子进程 ths 还在执行
th = new Thread(thStart);
th.isBackGround = true th.Start();
}