My Hindi Forum

Go Back   My Hindi Forum > Miscellaneous > Tech Talks
Home Rules Facebook Register FAQ Community

Reply
 
Thread Tools Display Modes
Old 20-01-2010, 07:25 PM   #1
abhisays
Administrator
 
abhisays's Avatar
 
Join Date: Dec 2009
Location: Bangalore
Posts: 16,772
Rep Power: 137
abhisays has a reputation beyond reputeabhisays has a reputation beyond reputeabhisays has a reputation beyond reputeabhisays has a reputation beyond reputeabhisays has a reputation beyond reputeabhisays has a reputation beyond reputeabhisays has a reputation beyond reputeabhisays has a reputation beyond reputeabhisays has a reputation beyond reputeabhisays has a reputation beyond reputeabhisays has a reputation beyond repute
Send a message via Yahoo to abhisays
Question servlet a singleton?

Is servlet a singleton class?
__________________
अब माई हिंदी फोरम, फेसबुक पर भी है. https://www.facebook.com/hindiforum
abhisays is offline   Reply With Quote
Old 21-01-2010, 06:14 AM   #2
javaguru
Member
 
javaguru's Avatar
 
Join Date: Dec 2009
Posts: 50
Rep Power: 15
javaguru is on a distinguished road
Smile

No servlets are not singleton..

The Servlet API does not restrict the creation of a particular Servlet class to a single instance, therefore it is not a Singleton.
javaguru is offline   Reply With Quote
Old 15-08-2010, 08:45 AM   #3
slicegan2
Junior Member
 
Join Date: Aug 2010
Posts: 6
Rep Power: 0
slicegan2 is on a distinguished road
Default

The Singleton's purpose is to control object creation, limiting the number to one but allowing the flexibility to create more objects if the situation changes. Since there is only one Singleton instance, any instance fields of a Singleton will occur only once per class, just like static fields.

Singletons often control access to resources such as database connections or sockets. For example, if you have a license for only one connection for your database or your JDBC driver has trouble with multithreading, the Singleton makes sure that only one connection is made or that only one thread can access the connection at a time. If you add database connections or use a JDBC driver that allows multithreading, the Singleton can be easily adjusted to allow more connections.

Moreover, Singletons can be stateful; in this case, their role is to serve as a unique repository of state. If you are implementing a counter that needs to give out sequential and unique numbers (such as the machine that gives out numbers in the deli), the counter needs to be globally unique. The Singleton can hold the number and synchronize access; if later you want to hold counters in a database for persistence, you can change the private implementation of the Singleton without changing the interface.
===============
monokinis
Volunteer Abroad in Malawi
slicegan2 is offline   Reply With Quote
Reply

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT +5. The time now is 10:50 PM.


Powered by: vBulletin
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
MyHindiForum.com is not responsible for the views and opinion of the posters. The posters and only posters shall be liable for any copyright infringement.