private static void runServer(boolean virtual, boolean withLock)
throws IOException {
HttpServer httpServer = HttpServer
.create(new InetSocketAddress(8080), 0); // (1)
httpServer.createContext("/example",
new SimpleDelayedHandler(withLock)); // (2)
if (virtual) {
httpServer.setExecutor(
Executors.newVirtualThreadPerTaskExecutor()
); // (3)
} else {
httpServer.setExecutor(
Executors.newFixedThreadPool(200)
); // (4)
}
httpServer.start(); // (5)
}
|