|
Reason for platform independent |
|
Basics |
|
Popular java editors |
|
Java supports fundamental concepts |
|
Variable Types |
Singleton Purpose:
The Singleton's purpose is to control object creation, limiting the number of obejcts to one only. 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.
|
Singleton Example |
No comments:
Post a Comment