You will probably want to use a Thread. If the action takes a long time to accomplish that you would be preventing the Thread used by the server from returning to the thread pool. If enough requests are made then the thread pool that serves requests could be blocked, waiting for past requests to finish.
A few things to note:
1) Web servers are usually tuned to the resources on the computer they are hosted. They have configurations for the number of threads in the thread pool. Assuming that your web server is properly tuned, you may be disrupting the balance between responsiveness and resources the server was configured for, which could adversely affect all the applications running in the server. So be careful, spawn threads only when you need to, and check resource availability once your app is up and running so you can re-tune the web server as appropriate (perhaps adding more memory, or reducing the thread pool used for hosting requests).
2) If you spawn a new Thread, you won't be able to communicate with the client to send messages. Once the main thread hosting the request/response is done, the response is closed and you won't be able to talk to send anything their way again.
3) If you plan on using anything like the session, or any other shared object/scope make sure you go through the process of synchronized blocks to prevent corrupting data.
Joined: Oct 03, 2008
Basically the 1st message which I am sending to the user is a constant which will be sent immediately wherein the task which has to run in the background takes lot of time to ccomplish the task. So I wanted a solution to figure out this. So as per your suggestion I got to use the Thread and Do you see will there be any impact. In the background, I will be updating a particular table and which is taking lot of time..
Please throw your thought If I can continue using the thread for this situation or Is there any better approach?