using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace ch14_1_1
{
    class MyThread
    {
        public int count;
        public Thread thrd;
        public string s;
        public MyThread(string name)
        {
            count = 0;
            thrd = new Thread(this.run); // use method group conversion
            thrd.Name = name; // set the name of the thread
            thrd.Start(); // start the thread
        }
        // Entry point of thread.
        void run()
        {
            s = thrd.Name + " starting.\n";
            do
            {
                Thread.Sleep(50);
              //  Console.WriteLine("In " + thrd.Name +
              //                    ", count is " + count);
                s += "In " + thrd.Name + ", count is " + count + "\n";
                count++;
            } while (count < 10);
            s += thrd.Name + " terminating.\n";
        }
    }
}
