|
From: Pablo C. <pc...@ac...> - 2007-09-21 10:01:18
|
Hi Continuing with the problem I reported before (http://www.nabble.com/sending-the-response-in-a-separate-thread-tf4490414.html), I was doing some testing with threads in jetty 6. I have this code to initialize the server: Server server = new Server(); BoundedThreadPool treads = new BoundedThreadPool(); treads.setMinThreads(5); treads.setMaxThreads(10); server.setThreadPool(treads); Connector connector=new SelectChannelConnector(); connector.setPort(8090); server.setConnectors(new Connector[]{connector}); server.setHandler(new ThreadedHandler()); server.start(); The handler implements a simple handle method, which sleeps for some seconds and then send a response: public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException { try { System.out.println("Request Received"); Thread.sleep(10000); System.out.println("Request Processed"); } catch (InterruptedException e) { e.printStackTrace(); } response.setContentType("text/xml"); response.setStatus(HttpServletResponse.SC_OK); response.getWriter().println("<H1>HELLO WORLD</H1>"); response.getWriter().flush(); } Notice I'm writing a message at the beginning and at the end of the handle method. Now, If I make two request to the server (from a browser), I get this output: Request Received Request Processed Request Received Request Processed Notice that the second request did not start until the first one finishes. Is this correct? How could I make jetty to keep attending requests even when the previous one is blocked. Thanks -- ======================================================================== 0 0 0 Pablo Chacin | Dept. d'Arquitectura de Computadors 0 0 0 e-mail: pc...@ac... | UPC-Campus Nord. Modul D6-212 0 0 0 phone: +34 +93 405 4059 | Jordi Girona, 1-3 U P C fax: +34 +93 401 7055 | 08034 Barcelona - SPAIN www: http://personals.ac.upc.es/pchacin ======================================================================== |