예제 #1
0
 /// <summary>
 /// adds threads for all customers
 /// </summary>
 private void AddThreadsForAllCustomers()
 {
     foreach (var customer in Customers)
     {
         var thread = new Thread(customer.BuyItem);
         CustomerThreads.Add(thread);
     }
 }
예제 #2
0
 /// <summary>
 /// Creates all customer threads
 /// </summary>
 private void CreateAllCustomerThreads()
 {
     for (var i = 0; i < AmountOfCustomers - 1; i++)
     {
         var customer = Customers[i];
         var thread   = new Thread(customer.BuyItem);
         CustomerThreads.Add(thread);
     }
 }
예제 #3
0
        public void AddCustomer(string name)
        {
            ICustomer customer = _attendants.CreateCustomer(name);

            Customers.Add(customer);
            Thread thread = new Thread(() => customer.PurchaseItem());

            CustomerThreads.Add(thread);
        }