aspose file tools*
The moose likes Servlets and the fly likes User created threads in serlvets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "User created threads in serlvets" Watch "User created threads in serlvets" New topic
Author

User created threads in serlvets

karthic panneer
Ranch Hand

Joined: Sep 22, 2008
Posts: 57
Hi
After a long time i am asking a question.
I have a servlet deployed in tomcat, in that servlet i created a thread listening for some event, the thread will be created for each user. My question is will that thread cause performance issue.

Any Suggestions?

Thanks in advance
Karthic
sudhir nim
Ranch Hand

Joined: Aug 29, 2007
Posts: 212

What do you mean by thread created for each user? Do you create a new thread for each request?

if possible You should look for an alternative, creating threads with servlets are not good practise


[Servlet tutorial] [Servlet 3.0 Cook Book]
Vinod K Singh
Ranch Hand

Joined: Sep 30, 2008
Posts: 198
You need to think about removing these threads as well. If you are creating these threads to perform some tasks parallel then I would suggest to have a look at java.util.concurrent package available Java 5 onwards.


My Blog
karthic panneer
Ranch Hand

Joined: Sep 22, 2008
Posts: 57
Thanks for Reply

What do you mean by thread created for each user? Do you create a new thread for each request?


When a user login the thread will start for that user and it will be destroyed when the user logged out.

Thanks & Regards
Karthic.P
sudhir nim
Ranch Hand

Joined: Aug 29, 2007
Posts: 212

This seems a dangerous task to create a new thread for each logged in user. Thread management could be difficult and may leave some holes (i.e start thread when login, and destroy when logout).
again, starting threads within container isn't a good practice. I would like some experts to speak out on this thing.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
karthic panneer wrote:Thanks for Reply

What do you mean by thread created for each user? Do you create a new thread for each request?


When a user login the thread will start for that user and it will be destroyed when the user logged out.

Thanks & Regards
Karthic.P

Bad idea. Why do you need to do this?
 
Don't get me started about those stupid light bulbs.
 
subject: User created threads in serlvets