Ejemplo n.º 1
0
        public static bool doit()
        {
            MonitorSample sample = new MonitorSample();
            Thread        child  = new Thread(delegate(object o)
            {
                MonitorSample s = (MonitorSample)o;
                for (int i = 0; i < 3; i++)
                {
                    s.AddElement(i);
                }
            });
            Thread child2 = new Thread(delegate(object o)
            {
                MonitorSample s = (MonitorSample)o;
                for (int i = 0; i < 3; i++)
                {
                    bool ok = (s.DeleteElement() == i);
                    if (!ok)
                    {
                        throw new System.Exception();
                    }
                    // System.Diagnostics.Debug.Assert(ok);
                }
            });

            child.Start(sample);
            child2.Start(sample);
            child.Join();
            child2.Join();
            return(sample.IsEmpty());
        }
Ejemplo n.º 2
0
 public static bool Run()
 {
     return(MonitorSample.doit());
 }