Sorry, I guess I should clarify. See responses inline.
On 10/6/06, Jochen Wiedmann <[EMAIL PROTECTED]> wrote:
If the response arrives, then either of the synchronized methods handleResult or handleError is entered. The variable responseSeen is set to true and notify() is called. Finally, the synchronized method is left. At that point the method wait(timeout) is left. (Note, that this cannot happen while handleError or handleResult is running, because waitResponse is synchronized as well.) A TimeoutException is not thrown, because responseSeen is true. > From looking at the code, it seems like the > wait thread would wait for the full timeout No, because notify() is called.
If no one is waiting (because no one has called waitForResponse yet), the Object.notify() call has no effect. If a thread then enters the waitForResponse method, that thread will have no way of "knowing" that the response has arrived, unless it checks before it starts waiting for it. Consider the use case from the javadoc: TimingOutCallback callback = new TimingOutCallback(10 * 1000); XmlRpcClient client = new XmlRpcClient(url); client.executeAsync(methodName, aVector, callback); // <---- Response arrives now, callback.notify() is called but nobody is waiting try { return callback.waitForResponse(); } catch (TimeoutException e) { System.out.println("No response from server."); } catch (Exception e) { System.out.println("Server returned an error message."); } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]