Does tomcat spring beans need to worry about concurrency?

It's not entirely clear about Java, do I have to worry about compatibility issues when listing and swapping DTO objects in my spring java beans in one tomcat server application?

+3
source share
2 answers

In short, yes. Spring Beans can often be used by multiple threads. Pay particular attention to member variables in the Spring Bean. If they are mutable, either make them immutable, or coordinate access using locks (for example, with synchronization), ThreadLocal, etc.

+4
source

, . DTO?. , .

Spring beans , , ( ) .

beans DTO , DTO, beans , DTO . , .

java concurrency. Goetz, .

, , (The springsource), , DTO . google "DTO evil" .

0
source

Source: https://habr.com/ru/post/1705464/


All Articles