public void agentsFun()
            {
                // checks the number of price cuts
                while (Airlines.NumOfPriceCut < 21)
                {
                    Airlines airline1 = new Airlines();

                    if (newTicket < oldTicket)

                    {
                        Thread.Sleep(1000);

                        //Generates a Random credit card number between 5000 to 7000
                        Int32 creditCardNo = r2.Next(5000, 7000);
                        //Taking random amount of flight tickets
                        Int32 numOfTicket = r2.Next(1, 20);

                        OrderClass order = new OrderClass();

                        //Sets the values of object to send it to Encoder

                        order.SenderId   = Convert.ToInt32(Thread.CurrentThread.Name);
                        order.CardNumber = creditCardNo;
                        order.Amount     = numOfTicket;
                        order.UnitPrice  = newTicket;


                        String en_order = Encoder(order); // Converts the order object to string

                        MCB.setOneCell(en_order);         //Adding the string to encoder
                        Console.WriteLine("Agency {0} has everyday low price : ${1} each", Thread.CurrentThread.Name, newTicket);
                    }

                    else
                    {
                        Thread.Sleep(1000);

                        Int32 creditCardNo = r2.Next(5000, 7000); //Taking a random credit card number
                        Int32 numOfTicket  = r2.Next(1, 20);      //Taking a random amount of Tickets

                        OrderClass order = new OrderClass();
                        //Setting the values of object for sending it to encoder

                        order.SenderId   = Convert.ToInt32(Thread.CurrentThread.Name);
                        order.CardNumber = creditCardNo;
                        order.Amount     = numOfTicket;
                        order.UnitPrice  = newTicket;
                        String en_order = Encoder(order); // Converting the order object to string

                        MCB.setOneCell(en_order);         //Adding the string to encoder

                        Console.WriteLine("Agency {0} has everyday low price : ${1} each", Thread.CurrentThread.Name, newTicket);
                    }
                } //End while
            }     //End agentsFun
        // Airline thread calls the function
        public void UpdatePrice()
        {
            // No of Price cuts
            while (NumOfPriceCut < 6)
            {
                if (PriceCounter == 5)
                {
                    Int32 p = rng.Next(100, 900);
                    Console.WriteLine("* * * * * * New Price Is : " + p + " * * * * * * * *");
                    PriceCounter = 0;

                    if (p < FlightTicket)
                    {
                        NumOfPriceCut++;
                    }
                    TravelAgents.oldTicket = FlightTicket;
                    TravelAgents.newTicket = p;
                    Airlines.changePrice(p);
                }


                rwObj1.AcquireWriterLock(1000);
                try
                {
                    String en_order = MCB.getOneCell();//gets the order string from the  buffer
                    PriceCounter++;

                    OrderClass orderObject = Decoder(en_order); //Convert the string order to order object

                    OrderProcessing opObj = new OrderProcessing();
                    //Console.WriteLine(orderObject.SenderId);
                    Thread orderProcessing = new Thread(() => opObj.orderP(orderObject));
                    orderProcessing.Start();
                    // orderProcessing.Join();
                }

                finally { rwObj1.ReleaseWriterLock(); }

                if (NumOfPriceCut > 5)
                {
                    Console.WriteLine("The Airlines thread will terminate - No of price cuts completed"); //Print before termination of  thread
                }
            }
        } //End of method
            static void Main(string[] args)
            {
                Airlines airline1 = new Airlines();
                Thread   Airline  = new Thread(new ThreadStart(airline1.UpdatePrice));

                Airline.Start();

                TravelAgents agent1 = new TravelAgents();

                Airlines.priceCut += new pricecutEvent(agent1.FlightOnSale);

                Thread[] agents = new Thread[5];

                for (int i = 0; i < 5; i++)
                {
                    agents[i]      = new Thread(new ThreadStart(agent1.agentsFun));
                    agents[i].Name = (i + 1).ToString();
                    agents[i].Start();
                }
            }