• 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

confused by singlethread interface

 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
singlethread interface problem from Hanuman Deshmukh book at page 160,
it says that:
"The specification guarantees that if a servlet implements this interface, the container will not execute the service() method in more than one thread simultaneously."
I understand this is why it is OK for sample at page 161 based on above statement.
but I am not clear the following word from Hanuman Deshmukh book at page 160.
To avoid the performance problem, a servlet container may create multiple instance of the servlet class. In short, multiple requests will still be processed simultaneously but by different servlet instance.
I dont think the container whose singlethread interface implemented by this algrithm will make
the sample code at page 161 works fine. The reason seems simple, two instances(evevn they are different) can not wirte
any information in to the same files simultaneously .
Please help me,
Thanks,
 
Ranch Hand
Posts: 348
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Frank,
Please note there is a static variable instanceNumber declared in listing 10.3 to keep track different file name for each instance instanitated by container. (so no conflict here)..
In fact, if you reading down after listing 10.3 you will see the description about this static variable.
HTH
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic