HTTP スレッドプール サーバーをシャットダウンしたい。そのために、STDIN をリッスンする 1 つのスレッドを作成します。と入力shutdownすると、サーバーがシャットダウンされます。
コードは
public class WebServerShutdown extends Thread{
    Logger log = Logger.getLogger( WebServerShutdown.class.getName() );
    @Override
    public void run() {
        try {
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            //ThreadPool threadpool = new ThreadPool();
            String s;
            while ((s = in.readLine()) != null && s.length() != 0) {
                System.out.println(s);
                if(s.equalsIgnoreCase("shutdown")) {
                    ThreadPool.isStopped = true;
                    break;
                }
            }
        } catch (IOException ex) {
            log.info(new Date() + " Problem in reading Input from keyboard");
        }
        System.out.println("Thread comes out");
    }
 }
サーバーがリッスンするコード
    while( !(ThreadPool.isStopped) ) {
        Socket client_socket = null;
        try {
            System.out.println("try to accept socket");
            client_socket = serversocket.accept();
        } catch(IOException ie) {
            log.info(new Date() + " Server Stopped");
        }
        ThreadPool.threads.execute(new Worker(client_socket));          
    }
    System.out.println("Reached here");
ThreadPool.threads.shutdown();
serversocket.close();
log.info(new Date() + " WEBSERVER STOPPED");
しかし、1 つ問題があります。shutdown を書くと、その時点でサーバーがループに入り、クライアントの要求をリッスンします。そのため、クライアントにリクエストを送信すると、その後サーバーが閉じられます。
しかし、それは良くありません。シャットダウンを書くときはいつでも、他のクライアント要求を受け付けません。
上記のコードを正しくするのを手伝ってください。