• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlets

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi...
Is it necessary to have threads in servlets, because as it is, the service method run on multiple threads to cater to multiple client requests.
If needed, how can we use threads in servlets?
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
U need not worry abt managin threads. The Web container does the job for U.
The only thing that u need to know is that ur servlet is muti-threaded.
If u want to make it single threaded make it implement SingleThreadModel (Ensures that one request is processed at a time)
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should only use a Thread to carry out processes that are separate from the request - response cycle. For example, I have used Threads to manage a cache of data files, send email, and download XML formatted headlines. In every case these Threads are attached to separate utility objects, NOT servlet code.
Bill
 
reply
    Bookmark Topic Watch Topic
  • New Topic