A race condition occurs when multiple threads change shared state without adequate coordination, causing unexpected results or errors. It can arise when a Spring singleton bean holds mutable data that concurrent requests share. section 5.1.1
A shared comment processor
If concurrent calls use one mutable CommentProcessor, one thread may overwrite another’s comment, leaving it unclear which comment was processed. A prototype bean can provide a new processor for each call, but retrieve it inside the method; injecting it once into a singleton still reuses that instance. section 5.2.1
Figure 5.5 When multiple threads access a singleton bean, they access the same instance. If these threads try to change the instance simultaneously, they run into race conditions. The race condition causes unexpected results or execution exceptions if the bean is not designed for concurrency.

See how simultaneous changes to one singleton instance can produce unexpected results or execution exceptions. section 5.1.1
























