'scheduleWithFixedDelay incresing delay after 15 minutes

i used this code for answer, first 18 minutes is ok after that delay began to increase. Tried few times, in about 20 minutes, delay began increase. 3 seconds to delay is too much. I dont undestand why its increases and how to hold delay in about 2 seconds... Tried scheduleAtFixedRate also that problem, tried different amount of pools, no differ. if i use delay from 1 to 2 seconds after 17 minutes it began to increase from 1 sec to 3. Help please to make stable timeout in answer.

    SheduledExecutorService sheduler = Executors.newSheduledThreadPool(200);//(10);
    HttpServer server = HttpServer.create(new InetSocketAddress(serverPort), 0);//5);
    server.createContext("/report", (exchange -> {
        String respText = "";
        String requestText = CFG.getContent(exchange);
        if(requestText.contains("delay"))
            respText = "delay confirmed";
            
        exchange.getResponseHeaders().set("Content-Type","application/json");
        exchange.sendResponseHeaders(200, respText.getBytes().length);
        String textToSend = respText;
        //sheduler.scheduleAtFixedRate(() -> {
        sheduler.scheduleWithFixedDelay(() -> {
            OutputStream output = exchange.getResponseBody();
            try{
                output.write(textToSend.getBytes(StandartCharsets.UTF_8));
                output.flush();
            } catch (IOException e){
                e.printStackTrace();
            }
            excahnge.close();
            //}, 1, 2, TimeUnit.SECONDS);
            }, 2, 2, TimeUnit.SECONDS);
    
    }));
    server.serExecutor(scheduler);
    server.start();

trying:

            sheduler.schedule(() -> {
            OutputStream output = exchange.getResponseBody();
            try{
                output.write(textToSend.getBytes(StandartCharsets.UTF_8));
                output.flush();
            } catch (IOException e){
                e.printStackTrace();
            }
            excahnge.close();
            }, 2, TimeUnit.SECONDS);


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source