I have a controller called importController. importController has a method of return type void that calls an asynchronous method for a list of objects passed over the wire.
The asynchronous methods logic is backed by a method in another object in the spring context. As I understand it, all beans in the spring context are singleton by default.
Will the asynchronous method calls really run in tandem or will they be bottle necked by the call to the bean?
Thanks in advance for your help, Dylan
It doesn't matter if the bean is a singleton as long as it's method is not synchronized
That is to say, if you have a singleton with a public String foo()
method and it's called several times in different threads then foo's execution will be concurrent.
However, if foo is synchronized within the singleton bean like this : synchronized public String foo()
then the threads will "take turns" (not exactly but you get my point) to run the foo method.
Hope this helps
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.