When multiple users request the same resource method from a service class, how will requests be processed on the server?
How will the leisure service be performed for each request? What is the difference between the life cycle of a leisure service and a servlet?
For example, if the resource is given below, how it will be created and executed in the following scenarios:
case 1: two users simultaneously call two different methods
case 2: two users simultaneously use the same method
@Path("greet")
public class GreetingResource {
@GET
@Path("welcome/{username}")
@Produces(MediaType.TEXT_PLAIN)
public String sayWelcome(@PathParam("username") String User) {
return "Welcome!" + User;
}
@GET
@Path("hello/{username}")
@Produces(MediaType.TEXT_PLAIN)
public String sayHello(@PathParam("username") String User) {
return "Hello " + User;
}
}
source
share