while (started && !exiting) {
count(1);
- Socket s = ss.accept();
- createConnectActionServer(s).connectAsync();
+ final Socket s = ss.accept();
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ createConnectActionServer(s).connect();
+ } finally {
+ count(-1);
+ }
+ }
+ }).start();
}
// Will be covered by @link{Server#stop(long)} for timeouts
}
}
- /**
- * This method will be called on errors.
- * <p>
- * By default, it will only call the trace handler (so you may want to call
- * super {@link Server#onError} if you override it).
- *
- * @param e
- * the error
- */
- protected void onError(Exception e) {
- tracer.error(e);
- }
-
/**
* Change the number of currently serviced actions.
*
*
* @return the current number after this operation
*/
- int count(int change) {
+ private int count(int change) {
synchronized (counterLock) {
counter += change;
return counter;
}
}
+ /**
+ * This method will be called on errors.
+ * <p>
+ * By default, it will only call the trace handler (so you may want to call
+ * super {@link Server#onError} if you override it).
+ *
+ * @param e
+ * the error
+ */
+ protected void onError(Exception e) {
+ tracer.error(e);
+ }
+
/**
* Create a {@link Socket}.
*