srikanthradix
asked on
Need suggestion regarding Multi-threading/singleton
My Application will called by many threads. I have configured my application such that the configuration is
<bean id="ServiceFullFillmentCoo rdinator" class="com....BusinessServ iceCoordin atorImpl" singleton="false">
<property name="businessServices">
<map>
<entry key="0">
<bean class="com....BusinessServ iceFullfil lment"></b ean>
</entry>
</map>
</property>
</bean>
As you can see "BusinessServiceCoordinato rImpl" bean's singleton is set to false but the BusinessServiceFulfillment bean's singleton is set to true as it is true by default. So, when multiple threads calls my Application will there be any problems since the property of the bean is set as singleton=true? Please suggest.
<bean id="ServiceFullFillmentCoo
<property name="businessServices">
<map>
<entry key="0">
<bean class="com....BusinessServ
</entry>
</map>
</property>
</bean>
As you can see "BusinessServiceCoordinato
ASKER
Doesn't singleton=true means thread-safe?
My Understanding of singleton
Creates single object for all threads and when one thread is using this object, other threads has to wait until the thread that is using the object relinquishes control of it.
And also, I have one more question singleton=false
Does singleton=false means creates seperate objects for each and every thread?
Please correct me if I am wrong.
My Understanding of singleton
Creates single object for all threads and when one thread is using this object, other threads has to wait until the thread that is using the object relinquishes control of it.
And also, I have one more question singleton=false
Does singleton=false means creates seperate objects for each and every thread?
Please correct me if I am wrong.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the solution.
You need to ensure that the code in your bean is thread safe.