Add the code you should have to set an executor for a server that uses a fixed pool of threads.
Setting up a server with HttpServer
Set an executor
Report a typo
Sample Input 1:
5Sample Output 1:
5Write a program in Java 17
import com.sun.net.httpserver.HttpServer;
import java.lang.reflect.Field;
import java.util.Scanner;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
class Main {
public static void main(String[] args) throws Exception {
HttpServer server = HttpServer.create();
Scanner scanner = new Scanner(System.in);
int threads = scanner.nextInt();
configureExecutor(server, threads);
checkExecutor(server);
}
// Implement this method
private static void configureExecutor(HttpServer server, int threads) {
}
// Do not modify this code
public static void checkExecutor(HttpServer server) throws Exception {
Executor executor = server.getExecutor();
Field field = executor.getClass().getDeclaredField("maximumPoolSize");
field.setAccessible(true);
System.out.println(field.get(executor));
}
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.