I would like to execute some task after a user request in background. My initial idea is to create a work thread and execute it from a servlet. However, I do not want too many threads to be running at the same time so I will need something like a thread pool.
Since I am already using Spring with my web application, I am wondering if there is anything in Spring or other libraries I can use to handle this problem without having to implement my own codes.
creating your own threads is often not advisable within a container as this can screw up thread pooling, i.e. the container unexpectantly runs out of threads. There is good quartz support in spring which may do exactly what you need, e.g. you can configure that the background job runs synchronously or asynchronously.