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

Popular posts from this blog

Issues changing the value of an element in an array in matlab -

php - MySQLi binding parameters in a prepared statement doesn't work unless inserted after "WHERE" -

vb.net - Alternative to the T-SQL AS keyword -