public void Allocator() { Console.WriteLine("Allocator Thread started : " + Thread.CurrentThread.ManagedThreadId); int TrdIndx = 0; while (true) { //block operation lock (TriggeredFilePaths) { System.Threading.Monitor.Wait(TriggeredFilePaths); if (TriggeredFilePaths.Count > 0) { try { String data = TriggeredFilePaths.Dequeue(); Console.WriteLine(data + " got File "); Compressor cm = new Compressor(data); while (JobPool[TrdIndx].IsAvailable != true) { TrdIndx = (TrdIndx + 1) % MAXTHREAD; } Console.WriteLine(" Found jobPool for file " + data + " TrdIndx -" + TrdIndx); JobPool[TrdIndx].CompObj = cm; JobPool[TrdIndx].IsAvailable = false; Console.WriteLine(" Calling Notify " + JobPool[TrdIndx].CompObj); JobPool[TrdIndx].Notify(); Console.WriteLine(" after Notify "); } catch (Exception ex) { Console.WriteLine(" Allocator Exception - " + ex.Message); } } } } }
public void Init(CmpQPusher cmpQ) { cmpQPusher = cmpQ; CompObj = new Compressor(string.Empty); TrdObj.Start(); }