NOTE

Thread Safety

Mutable instance fields in singleton Spring MVC objects can cause problems under concurrent updates. These notes examine thread-safety approaches through that case.

JavaCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

1. Thread-Safety Problem

Spring MVC is singleton by default, so problems occur if an instance field is modified concurrently.

1.1. Solutions

  • Use ThreadLocal.
  • Use prototype scope instead.

2. Reference

Discussion

Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub