Don't wait for queued messages if the timeout is negative. This requires a very close timing of when it thinks it should do another loop and when it actually does the loop. Fixes #14.

This commit is contained in:
Andy Janata 2012-11-09 19:55:15 -08:00
parent aa7b199bdb
commit 9c65662997
1 changed files with 4 additions and 2 deletions

View File

@ -105,10 +105,12 @@ public class User {
* @throws InterruptedException * @throws InterruptedException
*/ */
public void waitForNewMessageNotification(final long timeout) throws InterruptedException { public void waitForNewMessageNotification(final long timeout) throws InterruptedException {
if (timeout > 0) {
synchronized (queuedMessageSynchronization) { synchronized (queuedMessageSynchronization) {
queuedMessageSynchronization.wait(timeout); queuedMessageSynchronization.wait(timeout);
} }
} }
}
/** /**
* This method blocks if there are no messages to return, or perhaps if the queue is being * This method blocks if there are no messages to return, or perhaps if the queue is being