abount the singleton beans of spring -
i reading 《spring in action》, , says "singleton beans in spring don't maintain state because they're shared among multiple threads", in opinion, bean in spring pojo, how can not maintain state?
i reading 《spring in action》, , says "singleton beans in spring don't maintain state because they're shared among multiple threads", in opinion, bean in spring pojo, how can not maintain state?
yes, it's better spring/singleton not have state (of course can uses other spring/singletons [also them without state]) can call methods different threads without worring messed state (it doesn't have 1 :-)). let's think calculator stores intermediate results inside internal stack, can happen if 2 threads try calculate @ same time?
a spring/singleton annotated (and if it's not it's be) , lives inside spring context , it's not pojo.
if want have spring/bean state have use scope "prototype", kind of scope every time bean difference instance.
sorry bad english
Comments
Post a Comment