• 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: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hai!

What is meant by ThreadSafe?
Thanks in Advance. Bye...
M.VijayaLakshmi.
 
Desperado
Posts: 3226
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The normal servlet behavior is that multiple simultaneous requests are dispatched to multiple threads concurrently accessing the same servlet instance.
If a servlet implements the SingleThreadModel interface (which is a marker interface like Serializable), the system guarantees that there will not be simultaneous access to the same servlet instance.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hai,
Default value of "thread safe = true".
servlet or JSP file may be accessed by multiple users..
servlet engine creates a separate thread for each and evry user.
if u don't want your sevlet to be accesed by multiple users at a time,
you have to implement the servlet class with "singlethreadmodel"
interface.This interface does not contain any methods.It is just a flag.
In JSP,You have to set threadsafe as false
Thanx.
Prabu.U
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For more information on writing thread-safe code, check out this section of Sun's java tutorial on synchronizing threads:
http://java.sun.com/docs/books/tutorial/essential/threads/multithreaded.html

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Prabhu
I would like to clarify my doubt with you regarding SingleThreadModel. In case of Servlet class which implements, SingleThreadModel you said that Servlet will not be accessed by two threads at a time. What I know that, In case of SingleThreadModel, we can create a pool of Instances which can be used for managing the client requests. We can also set the number of Instances to be created and one instances can be dedicated to one request. If more request come then , it will be put in Wait state.
My question is that we can create pool of instances which can be used not like one servlet instance. Please clarify.
Thanks
Rakesh
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic