My reply e-mail address was wrong in the prior message. Sorry about that.
The following sample code for the lock statement is on page 112 of the
O'Reilly book "C# Essentials". Can somebody explain to me why this
recursive class definition of LockTest does not cause an infinite number of
LockTest objects to be created (i.e., until it consumes all available
memory)? I don't understand why only two threads are created.
using System;
using System.Threading;
class LockTest
{
static void Main()
{
LockTest lt = new LockTest();
Thread t = new Thread(new ThreadStart(lt.Go));
t.Start();
lt.Go();
}
void Go()
{
lock(this)
for (char c='a'; c<='z'; c++)
Console.Write(c);
}
}