我正在使用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();
}
}
Run Code Online (Sandbox Code Playgroud)
我打开浏览器选项卡,localhost:8080然后打开第二个选项卡localhost:8080
这次第一个标签将等待5秒,第二个标签将等待10秒
为什么会这样?