static void Main(string[] args) { Console.WriteLine("Otwieramy Pocztę"); List <Thread> threads = new List <Thread>(); PostOffice postOffice = new PostOffice(); for (int i = 0; i < 100; i++) { Client c = new Client(i + 1, postOffice); threads.Add(new Thread(c.VisitPost)); } foreach (Thread t in threads) { t.Start(); } }
static void Main(string[] args) { Console.WriteLine("Otwieramy Pocztę"); PostOffice po = new PostOffice(); List <Client> clients = new List <Client>(); List <Thread> clientsTh = new List <Thread>(); for (int i = 0; i < 100; i++) { Client c = new Client(i, po); clients.Add(c); clientsTh.Add(new Thread(c.Task)); } Console.WriteLine("Start obsługi klientów"); foreach (Thread t in clientsTh) { t.Start(); } }
public Client(int id, PostOffice po) { this.Id = id; this.postOffice = po; }