}
@Test
public void test() {
CountDownLatch latch = new CountDownLatch(1);
BooleanMutex mutex = new BooleanMutex(true);
Producer producer = new Producer(mutex, 10);
Cosumer cosumer = new Cosumer(latch, 20, 50);
executor.submit(producer);
executor.submit(cosumer);
try {
Thread.sleep(30 * 1000L);
} catch (InterruptedException e) {
}
mutex.set(false);
try {
latch.await();
} catch (InterruptedException e) {
}
executor.shutdown();