Listing 1: The primary thread creates two threads

#using <mscorlib.dll>
using namespace System;
using namespace System::Threading;

__gc class Th01
{
   int loopStart;
   int loopEnd;
   int dispFrequency;

public:
   Th01(int startValue, int endValue, int frequency)
   {
      loopStart = startValue;
      loopEnd = endValue;
      dispFrequency = frequency;
   }

/*1*/   void ThreadEntryPoint()
   {
/*2*/      String *threadName = Thread::CurrentThread->Name;
      
      for (int i = loopStart; i <= loopEnd; ++i)
      {
         if (i % dispFrequency == 0)
         {
            Console::WriteLine(S"{0}: i = {1,10}", threadName,
i.ToString()); } } Console::WriteLine(S"{0} thread terminating", threadName); } }; int main() { /*3a*/ Th01 *o1 = new Th01(0, 10000000, 200000); /*3b*/ Thread *t1 = new Thread(new ThreadStart(o1,
&Th01::ThreadEntryPoint)); /*3c*/ t1->Name = S"t1"; /*4a*/ Th01 *o2 = new Th01(-20000000, 0, 200000); /*4b*/ Thread *t2 = new Thread(new ThreadStart(o2,
&Th01::ThreadEntryPoint)); /*4c*/ t2->Name = S"t2"; /*5*/ t1->Start(); /*6*/ t2->Start(); Console::WriteLine(S"Primary thread terminating"); } — End of Listing —