senpost
4/20/2011 - 1:35 AM

Each thread has a separate stack

Each thread has a separate stack

static void Main(string[] args)
{
    //Thread has separate call stack
    Thread newThread = new Thread(()=> Print(5));
    newThread.Start();

    Print(3);
    Console.ReadLine();
}

static void Print(int x)
{
    for (int i = 0; i < x; i++)
    {
        Console.Write(x);
        Thread.Sleep(10);       
    }
}

//Output
//53535355