Exemple #1
0
        static void Main(string[] args)
        {
            f = new FileThreadUnsafe<int>(10);

            for (int i = 1; i <= 10; i++)
            {
                try
                {
                    f.Enfiler(i);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Erreur : " + e.Message);
                }
            }
            AfficherNBElement(f.NbElements());

            th1 = new Thread(Lancement1);
            th2 = new Thread(Lancement2);

            th1.Start();
            th2.Start();

            th1.Join();
            th2.Join();

            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            f = new FileThreadUnsafe<int>(10);

            for (int i = 0; i < 100; i++)
            {
                try { f.Enfiler(i); }
                catch (Exception e) { Console.WriteLine("La file est pleine"); break; }
            }
            Console.WriteLine("Nombre d'élements: "+ f.NbElements());

            th1 = new Thread(TH1Func);
            th2 = new Thread(TH2Func);
            th1.Start();
            th2.Start();
            th1.Join();
            th2.Join();
        }