• 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 is equal to session

 
Ranch Hand
Posts: 594
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
servlet is multithreaded ,multithread means when many users access the same servlet then it will be multi threaded,each thread will serve single user.
when many users access a web application,session will be created for each users,

then Can I say that each thread is equal to session.
 
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi jacob,

you shouldn't make too many assumptions on how a servlet container may handle user requests. Usually each user request is handled by a different thread to be able to handle as many users as the hardware allows. But this doesn't mean that there has to be a one-to-one mapping between users and threads. This is simply an implementation detail of the container and you shouldn't build your application on these assumptions.

The only thing you should really take care of is that a servlet may be accessed simultaneously by more than one threads and therefore servlets in general have to be thread-safe!

Marco
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider that a single user can send more than one request at a time (eg multiple tabs). They need different threads but share the same session, so no you cannot say that.
 
Marco Ehrentreich
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Additionally I should have mentioned that a bunch of servlet containers in a clustered environment may allow session migrating to another node. If a session migrates to another node a totally different host may server subsequent requests of the same session which are definitely handled by another thread - even another JVM.

Marco
[ September 24, 2008: Message edited by: Marco Ehrentreich ]
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by David O'Meara:
Consider that a single user can send more than one request at a time (eg multiple tabs). They need different threads but share the same session, so no you cannot say that.



GOOD EXPLANATIONS
 
reply
    Bookmark Topic Watch Topic
  • New Topic