Exemplo n.º 1
0
        public void DoIt()
        {
            // Initialise some threads
            int THREAD_COUNT = 25;             // How many threads to start

            Thread[] putThreads = new Thread[THREAD_COUNT];
            for (int i = 0; i < THREAD_COUNT; i++)
            {
                // Instantiate and start up the "put" threads:
                PutThread putter = new PutThread();
                putter.ThreadNum = i;

                ThreadStart ts     = new ThreadStart(putter.Put);
                Thread      thread = new Thread(ts);
                thread.Name   = i.ToString();
                putThreads[i] = thread;

                putThreads[i].Start();
            }

            // Wait for all the threads to finish, so we can display a "completed" message
            for (int i = 0; i < THREAD_COUNT; i++)
            {
                putThreads[i].Join();
            }
            Console.WriteLine("Not Received Person Objects: " + NotReceived);
            Console.Out.WriteLine("DoIt: PUT threads completed");
        }
Exemplo n.º 2
0
		public void DoIt()
		{
			// Initialise some threads
			int THREAD_COUNT = 25; // How many threads to start

			Thread[] putThreads = new Thread[THREAD_COUNT];
			for (int i = 0; i < THREAD_COUNT; i++)
			{
				// Instantiate and start up the "put" threads:
				PutThread putter = new PutThread();
				putter.ThreadNum = i;

				ThreadStart ts = new ThreadStart(putter.Put);
				Thread thread = new Thread(ts);
				thread.Name = i.ToString();
				putThreads[i] = thread;

				putThreads[i].Start();
			}

			// Wait for all the threads to finish, so we can display a "completed" message
			for (int i = 0; i < THREAD_COUNT; i++)
			{
				putThreads[i].Join();
			}
			Console.WriteLine("Not Received Person Objects: " + NotReceived);
			Console.Out.WriteLine("DoIt: PUT threads completed");
		}