Reputation: 1129
I am using spring tool suite 3.3.0.
I have a request mapping in that I receive from client and start processing and call a different thread for my purpose.
Is it possible to send response from worker thread?
Code: @RequestMapping(value = "/rcv", method = RequestMethod.POST)
public @ResponseBody String home() { //receving from client
Thread th = new Thread();
// my thread process
}
Upvotes: 2
Views: 521
Reputation: 57421
No. It should work another way.
On first cll you start the thread nd store it somewhere e.g. in session. Then from client you call it from time to time e.g. by AJAX call each second you ask whether the thread's job is done. BTW it could also show the progress.
When thread has done the job the result is stored again in session and on next AJAX call the result is returned to client
Upvotes: 3