要是一个线程进行到一半,想终止了,怎么办呢?请看代码:
usingSystem;
usingSystem.Threading;
classThreadTest
{
//工作线程的方法
publicstaticvoidWorkerThreadMethod1()
{
//获得当前正在执行的线程对象
Thread w1=Thread.CurrentThread;
w1.Name="工人1号正在工作中
";
for(inti=1; i<10;i++)
{
Thread.Sleep(400);
Console.WriteLine(w1.Name);
if(i==4)
{
Console.WriteLine("累死我了,不想做了");
//终止线程
w1.Int