title: Set the time out on Rest end points
body: <p>I am trying to impose time limit on http end points. </p>
  
  <p>In the example below, I am aiming that this method shall be executed before 5 seconds. If it is taking more time, I would like to throw exception and return error to client.</p>
  
  <pre><code>Spring : 4.1.7
  Jersey 1.1.9
  </code></pre>
  
  <p><strong>Code</strong></p>
  
  <pre><code>import javax.ws.rs.GET;
      import javax.ws.rs.Path;
      import javax.ws.rs.PathParam;
      import javax.ws.rs.Produces;
      import javax.ws.rs.core.Response;
  
  
      @Path("/pets")
      @Component
      public class PetsController {
  
  
        @GET
        @Produces({MediaTypeApi.JSON, MediaTypeApi.XML})  
        //Timeout of 5 secs
        public List&lt;Pet&gt; getPets() {
         //Return
        }
      }
  </code></pre>
  
  <p>Any idea to handle this in better way considering optimum utilization of threads.</p>