Java Extreme Programming Cookbook by Eric M. Burke, Brian M. Coyner The unconfirmed error reports are from readers. They have not yet been approved or disproved by the author or editor and represent solely the opinion of the reader. Here's a key to the markup: [page-number]: serious technical mistake {page-number}: minor technical mistake : important language/formatting problem (page-number): language change or minor formatting problem ?page-number?: reader question or request for clarification This page was updated April 16, 2008. UNCONFIRMED errors and comments from readers: [83] Example 4-11; This test can miss the completion of the search if it happens quickly (or, perhaps, in a higher priority thread). The code: // 1. Execute the search sm.search("eric", mockListener); // 2. Wait for the search to complete synchronized (mockListener) { mockListener.wait(2000); } should be replaced by: // 1. Execute the search synchronized (mockListener) { sm.search("eric", mockListener); // 2. Wait for the search to complete mockListener.wait(2000); } This prevents the search thread from calling the notifyAll() method before the corresponding wait() method is called. Another, possibly better solution, is to replace the getSearchModelEvent method in Example 4-10 with one that waits itself: public synchronized SearchModelEvent waitForSearchModelEvent (long timeout) throws InterruptedException { if (this.evt == null) wait (timeout); return this.evt; } This method also works in the case where the search is performed in the calling thread (which would fail in the existing implementation).