}
/**
- * Set the maximum number of actively communicating threads allowed
+ * Set the maximum number of actively communicating (async) threads allowed.
+ *
+ * This has no effect on synchronous communication.
*/
public void setMaxThreads(int max) {
maxThreads = max;
Runnable r = new Runnable() {
public void run() {
Object response;
- boolean failed = false;
try {
request.send();
while ((response = request.recv()) != null)
request.handler.onResponse(request, response);
+ request.handler.onComplete(request);
+
} catch (Exception ex) {
request.handler.onError(request, ex);
- failed = true;
} finally {
// server communication has completed
activeThreads--;
}
- if (!failed)
- request.handler.onComplete(request);
-
if (activeThreads < maxThreads) {
try {
manageAsyncRequest(pendingThreadQueue.remove());