I have the following code:
====================
public class Test
{
Thread thread;
ThreadStart threadStart;
int i;
public void Run()
{
threadStart = new ThreadStart(Work);
thread = new Thread(threadStart);
thread.Name = "" +(i++ );
thread.Start();
}
public void Work()
{
int i = 0;
while (i < 10)
{
Thread.Sleep(200);
Console.WriteLine(Thread.CurrentThread.Name);
}
}
}
void main(string[] args)
{
Test test = new Test();
for (int i = 0; i < 100; i++)
{
test.Run();
}
}
======================
My question is, each time Run() is called a new thread seems to be
started. Can anyone shed light onto why any existing thread running
for the "thread" member variable isn't aborted? Or does it just
restart "thread"? The thread.Name is different each time though.