title: REST API + Java Multithreaded
body: <p>I managed to build a small REST API using eclipse. The following code works:</p>
  
  <pre><code>@Path("Info")
  public class Rest {
  
  @POST
  @Path("/stats/{j}") 
  @Produces("application/json")
  public Response Status(@PathParam("j") String j) throws JSONException{
    JSONObject jsonObject = new JSONObject();
     String status = j;
     .
     .
   return Response.status(200).entity(result).build();
  }
  }
  </code></pre>
  
  <p>Could you advise me on how make this a multithreaded? I have an idea of what is multithreaded but I need some input on how to go about creating this code as multithreaded.  was thinking of creating another class that implements Runnable:</p>
  
  <pre><code>class Demo implements Runnable {
    .
    .
  
  }
  </code></pre>
  
  <p>Then, in my function Status(@PathParam("j") String j), I create an object of class Demo, For example:</p>
  
  <pre><code>public Response Status(@PathParam("j") String j) throws JSONException{
      Demo newThread = new Demo();
      JSONObject jsonObject = new JSONObject();
     String status = j;
     .
     .
   return Response.status(200).entity(result).build();
  }
  }
  </code></pre>
  
  <p>Thank you in advance!</p>