简体   繁体   中英

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

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) eg the thread pool for handling the requests?

Found out ExecutorServiceProvider which can be injected directly in Jersey:

@Inject
private final ExecutorServiceProvider executorServiceProvider;

Then

ExecutorService executorService = executorServiceProvider.getExecutorService();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM