public void stress6() { CircularQueue <int?> queue = new CircularQueue <int?>(5); // start two getters and two putters and let 'em duke it out... Thread t1 = new Thread( delegate() { try { for (int i = 0; i < 100; i++) { Assert.IsTrue(queue.Put(i)); } } catch (ThreadInterruptedException e) { Console.WriteLine(e); } } ); Thread t2 = new Thread( delegate() { try { for (int i = 0; i < 100; i++) { Assert.IsTrue(queue.Put(i)); } } catch (ThreadInterruptedException e) { Console.WriteLine(e); } } ); Thread t3 = new Thread( delegate() { try { for (int i = 0; i < 100; i++) { Assert.IsNotNull(queue.Get()); } } catch (ThreadInterruptedException e) { Console.WriteLine(e); } } ); Thread t4 = new Thread( delegate() { try { for (int i = 0; i < 100; i++) { Assert.IsNotNull(queue.Get()); } } catch (ThreadInterruptedException e) { Console.WriteLine(e); } } ); t1.Start(); t2.Start(); t3.Start(); t4.Start(); harvest(t1); harvest(t2); harvest(t3); harvest(t4); }
public void construct5() { CircularQueue <int?> queue = new CircularQueue <int?>(); Assert.AreEqual(10, queue.Size()); }
public void put() { CircularQueue <int?> queue = new CircularQueue <int?>(); queue.Put(null); }