static bool ThreadStopped = false;
static void Amba()
{
for (int i = 1; i <= 10; i++)
{
Console.WriteLine(i.ToString());
Thread.Sleep(1000);
if (ThreadStopped)
break;
}
}
static void Main(string[] args)
{
new Thread(Amba).Start();
Console.WriteLine("Press any key to exit");
Console.ReadKey();
ThreadStopped = true;
}