Set an executor

Report a typo

Add the code you should have to set an executor for a server that uses a fixed pool of threads.

Sample Input 1:

5

Sample Output 1:

5
Write 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));
}
}
___

Create a free account to access the full topic