* object is added then one thread should complete. The remaining
* thread should complete after the addition of a second object.
*/
public void testBlockedRemoveWithAdd() {
Buffer blockingBuffer = BlockingBuffer.decorate(new MyBuffer());
Object obj = new Object();
// run methods will remove and compare -- must wait for add
Thread thread1 = new ReadThread(blockingBuffer, obj, null, "remove");
Thread thread2 = new ReadThread(blockingBuffer, obj, null, "remove");
thread1.start();
thread2.start();
// give hungry read threads ample time to hang
delay();
blockingBuffer.add(obj);
// allow notified threads to complete
delay();
// There should be one thread waiting.
assertTrue("There is one thread waiting", thread1.isAlive() ^ thread2.isAlive());
blockingBuffer.add(obj);
// allow notified thread to complete
delay();
// There should not be any threads waiting.