Что означает отставание сокета?
например, у меня есть веб-сервис
@WebService
public class Calculator {
public int sum(int a, int b) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return a + b;
}
public static final int threadCount = 10;
public static void main(String[] args) throws IOException {
Executor manyThreads = Executors.newFixedThreadPool(threadCount);
HttpServer server = HttpServer.create(new InetSocketAddress(8989), threadCount);
server.setExecutor(manyThreads);
server.start();
Endpoint ep = Endpoint.create(new Calculator());
HttpContext context = server.createContext("/calc");
ep.publish(context);
}
}
и клиент веб-сервиса
public static void main(String[] args) throws IOException {
CalculatorService service = new CalculatorService();
final Calculator calc = service.getCalculatorPort();
Executor executor = Executors.newFixedThreadPool(100);
for (int i = 0; i < 1000000; ++i) {
executor.execute(new Runnable() {
public void run() {
try {
int currentThreads = runningThreads.incrementAndGet();
int res = calc.sum(10, 10);
System.out.println("Running threads: " + currentThreads + " Result: " + res);
} catch (ClientTransportException e) {
System.out.println("connection refused");
} finally {
runningThreads.decrementAndGet();
}
}
});
}
System.in.read();
}
на сервере только 10 рабочих потоковДля backlog установлено значение 10, поэтому может быть 10 принятых соединений и 10 соединений, ожидающих в очереди, и в любом другом соединении будет отказано, я прав?
Может быть не так, как я не получаю ClientTransportException.
Не могли бы вы объяснить, что происходит с соединениями и почему не существует ClientTransportException.