• 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

Thread for a request

 
Ranch Hand
Posts: 358
Firefox Browser Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From HFSJSP, 2e, chapter 4:
The Container finds the correct servlet based on the URL in the request, creates or allocates a thread for that request, and calls the servlet’s service() method, passing the request and response objects as arguments.

What's the relationship between the request and the allocated thread? A thread ( in small case ) is a virtual CPU with code and data to work. In the above statement, what are the code and data?
 
Ranch Hand
Posts: 924
1
Netbeans IDE Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
there is always(except in case of SingleThreadModel interface) single instance of servlet running. for each request , a new thread is created and allocated to serve that request. this thread or as you say piece of execution/cpu cycle executes service(request, response) which in turn dispatches the request to one of doGet or doPost http method. so basically the code on which thread operates is one in service, doGet/doPost method. the data for thread is any local variables you might have defined in your servlet.
reply
    Bookmark Topic Watch Topic
  • New Topic