Skip to content

Commit 649b14a

Browse files
committed
Update App.java
additional explanation about the risks of using the singleton pattern, as requested by @iluwatar
1 parent fe625c4 commit 649b14a

File tree

1 file changed

+8
-2
lines changed
  • singleton/src/main/java/com/iluwatar

1 file changed

+8
-2
lines changed

singleton/src/main/java/com/iluwatar/App.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33
/**
44
*
55
* Singleton pattern ensures that the class (IvoryTower) can have only one
6-
* existing instance per java vm instance and provides global access to that it.
7-
*
6+
* existing instance per java classloader instance and provides global access to it.
7+
*
88
* http://stackoverflow.com/questions/70689/what-is-an-efficient-way-to-implement-a-singleton-pattern-in-java
99
*
10+
* The risk of this pattern is that bugs resulting from setting a singleton up in a distributed environment can
11+
* be tricky to debug, since it will work fine if you debug with a single classloader. Additionally, these
12+
* problems can crop up a while after the implementation of a singleton, since they may start out synchronous and
13+
* only become async with time, so you it may not be clear why you are seeing certain changes in behaviour.
14+
*
15+
* http://stackoverflow.com/questions/17721263/singleton-across-jvm-or-application-instance-or-tomcat-instance
1016
*/
1117
public class App {
1218

0 commit comments

Comments
 (0)