I would like to share an object between various instances of objects of the same class.
Conceptually, while my program is running, all the objects of class A access the same object of class B.
I've seen that static
is system-wide and that its usage is discouraged. Does that mean that if I've got another program running on the same JVM that instantiates objects of class A, these objects could potentially access the same B object as the one accessed in the previous program?
What are generally the flaws behind using static fields?
Are there any alternatives (that do not require a huge effort of implementation)?