I have two requests in tomcat. One HTTP request will create a thread. Client can use a new HTTP request to terminate the same thread.
Is it possible to do that? If possible how?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Oh please, don’t spawn unmanaged threads yourself in a Java EE application. Use an
Executorwith a fixed thread pool. UseCallableas tasks and useFutureas future results.Create one on application’s startup (e.g. in
ServletContextListeneror servlet’sinit()).On first request, submit a task to it, get the
Futureresult. The below example assumes that it’s of typeStringand thatTaskis aCallable<String>:Store this in the session:
On any subsequent request in the same session, you could get it from the session and check if it’s done or not and if necessary cancel it.
See also: