Put one thread to sleep until a condition is resolved in another thread
问题 Here are two chunks of code that accomplish (what I think is) the same thing. I basically am trying to learn how to use Java 1.5's concurrency to get away from Thread.sleep(long). The first example uses ReentrantLock, and the second example uses CountDownLatch. The jist of what I am trying to do is put one thread to sleep until a condition is resolved in another thread. The ReentrantLock provides a lock on the boolean I'm using to decide whether to wake the other thread or not, and then I use