replace condvar with CountDownLatch
fixes #754