added count down latch class, inspired by java.util.concurrent.CountDownLatch
fixed non-deterministic event spec

Due to an improperly synchronized array, event spec sometimes fails; this issue has been solved using a count down latch instead