108109110111112113114115116117118
} try { FailoverValve valve = new FailoverValve (); valve.enter(); valve.leave(); valve.leave(); // extra leave call, should throw an exception fail("Valve.close didn't generate an exception, Valve is not safe!"); } catch (Throwable e)
127128129130131132133134135136137
final FailoverValve valve = new FailoverValve(2000); final Slot slot = new Slot(); // prevent the valve from being possible to close valve.enter(); new Thread(new Runnable() { public void run() {
165166167168169170171172173174175
final FailoverValve valve = new FailoverValve(2000); final Slot slot = new Slot(); // flip-flop the valve valve.enter(); valve.leave(); new Thread(new Runnable() { public void run()
203204205206207208209210211212213
// prevent the valve from being possible to close log.info("entering the valve"); valve.enter(); // attempt to close the valve from 10 concurrent threads for(int i = 0; i < THREAD_COUNT; i++) { slot[i] = new Slot();