Skip to main content

Thread per request model in Spring

Thread safety

Annotation @Controllers

Controllers are thread safe

Annotation @Service

In theory service should be stateless.

  • Service is just a non-thread safe single.
  • Spring only manages lifecycle of such bean.
  • It means that shared objects shouldn't be exist in service
  • Or use prototype @Scope