public synchronized void stop ( ) { // Mark us closed stopped = true ; try { // Kick the server accept loop serverSocket . close ( ) ; // acquire all semaphores so that we wait for all connections to finish before we report back as closed semaphore . acquireUninterruptibly ( MAXIMUM_CONCURRENT_READERS ) ; } catch ( IOException e ) { log . log ( Level . SEVERE , "Caught exception: " , e ) ; } }
Stops the server . Server is shutdown after processing of the current request is complete .