public void MultithreadAddRemove()
        {
            const int count = 10;

            RegionOidAllocationTest[] roas = new RegionOidAllocationTest[count];
            object obj = new object();

            Monitor.Enter(obj);

            for (int i = 0; i < count; i++)
            {
                RegionOidAllocationTest roaInstance = new RegionOidAllocationTest();
                roaInstance.id    = i;
                roaInstance.sync  = obj;
                roaInstance.m_reg = m_reg;
                roas[i]           = roaInstance;
                Thread.MemoryBarrier();

                Thread thr = new Thread(new ThreadStart(roaInstance.ThreadMain));
                thr.Start();
            }

            while (true)
            {
                Thread.Sleep(100);
                bool done = true;
                for (int i = 0; i < count; i++)
                {
                    RegionOidAllocationTest roa = roas[i];
                    if (!roa.finished)
                    {
                        done = false;
                        break;
                    }
                }

                if (done)
                {
                    break;
                }
            }

            Console.Out.WriteLine("done.");
        }
        public void MultithreadAddRemove()
        {
            const int count = 10;
            RegionOidAllocationTest[] roas = new RegionOidAllocationTest[count];
            object obj = new object();
            Monitor.Enter(obj);

            for (int i = 0; i < count; i++)
            {
                RegionOidAllocationTest roaInstance = new RegionOidAllocationTest();
                roaInstance.id = i;
                roaInstance.sync = obj;
                roaInstance.m_reg = m_reg;
                roas[i] = roaInstance;
                Thread.MemoryBarrier();

                Thread thr = new Thread(new ThreadStart(roaInstance.ThreadMain));
                thr.Start();
            }

            while (true)
            {
                Thread.Sleep(100);
                bool done = true;
                for (int i = 0; i < count; i++)
                {
                    RegionOidAllocationTest roa = roas[i];
                    if (!roa.finished)
                    {
                        done = false;
                        break;
                    }
                }
                if (done)
                    break;
            }

            Console.Out.WriteLine("done.");
        }