public static void Main (string[] args) { int max_consument = 10; int max_producent = 10; uint max_producent_products = 100; Consument[] conx = new Consument[max_consument]; Producent[] prox = new Producent[max_producent]; Thread[] thx = new Thread[max_consument + max_producent]; for (int i = 0; i < max_producent; i++) { prox [i] = new Producent (max_producent_products); thx [i] = new Thread (new ThreadStart (prox [i].produceThings)); } for (int i = 0; i < max_consument; i++) { conx [i] = new Consument (); thx [i + max_producent] = new Thread (new ThreadStart (conx [i].tryReadAndGuess)); } for (int i = 0; i < (max_producent + max_consument); i++) { thx [i].Start (); } Thread.Sleep (100); for (int i = 0; i < (max_producent + max_consument); i++) { thx [i].Join (); } }
public static void unregisterConsument (Consument c) { m_consumentList.WaitOne (); consumentList.Remove (c); m_consumentList.ReleaseMutex (); }