我正在使用Undertow创建一个简单的应用程序。
public class App {
public static void main(String[] args) {
Undertow server = Undertow.builder().addListener(8080, "localhost")
.setHandler(new HttpHandler() {
public void handleRequest(HttpServerExchange exchange) throws Exception {
Thread.sleep(5000);
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
exchange.getResponseSender().send("Hello World");
}
}).build();
server.start();
}
}
我在浏览器标签页上打开了localhost:8080
,然后我又打开了第二个标签页,同样是在localhost:8080
上。
这一次,第一个标签页将等待5秒钟,而第二个标签页将等待10秒钟。
为什么会这样呢?