Is there a common shared thread pool / executor in JAX-RS on server side?

Viewed 17

I have a JAX-RS service:

@GET
@Path("/foo")
/* ... */
public Response show() {
  // Execute an async  task here

  return Response.ok().entity(result).build();
}

I am aware we can create a thread pool service, or use the JVM commonPool(), but I wonder if there is an internal thread pool in JAX-RS standard or implementation (I use Jersey with Jetty) e.g. the thread pool for handling the requests?

1 Answers

Found out ExecutorServiceProvider which can be injected directly in Jersey:

@Inject
private final ExecutorServiceProvider executorServiceProvider;

Then

ExecutorService executorService = executorServiceProvider.getExecutorService();
Related