Replace Thread.yield with CountDownLatch

This makes multi-threaded tests more reliable on multiple
platforms.