- synchronized the reset() method

- avoid synchronization in waitForResponse() if possible.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@1684 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
ray
2005-08-03 20:43:46 +00:00
parent e02258a053
commit 489e3a72c7
@@ -73,7 +73,7 @@ public class ServiceWaiter
/**
* Reset the service waiter so that it can be used again.
*/
public void reset ()
public synchronized void reset ()
{
_success = 0;
_argument = null;
@@ -116,9 +116,11 @@ public class ServiceWaiter
* @return true if a success response was posted, false if a failure
* repsonse was posted.
*/
public synchronized boolean waitForResponse ()
public boolean waitForResponse ()
throws TimeoutException
{
if (_success == 0) {
synchronized (this) {
while (_success == 0) {
try {
// wait for the response, timing out after a while
@@ -139,6 +141,8 @@ public class ServiceWaiter
// fall through and wait again
}
}
}
}
return (_success > 0);
}