Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Threads In Servlets  RSS feed

 
Girish Babu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

for one of my requirements i am forced to create threads inside a servlet adn it is kind of working fine,

but what i want to understand is, will it have any side effects? will it affect the performance of my application in any way, because i am opening a socket connection to some other server from within my servlet and i want a thread to keep track of my servers socket?

please do tell me is it ok do this or is there anyother way to achieve the same..

thanks in advance,
 
Sarath Mohan
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but what i want to understand is, will it have any side effects?


You need to follow same principles when you code service() method. Always think that class instances are being accessed by multiple threads. So using member varibles and other shared resources should be thread safe. I don't see any other side effects
 
Scott Duncan
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try here.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!