1

A single controller in Spring usually has many Request Mappings. Many requests may hit APIs belonging to one controller(means one class) at the same time. Does n't it lead to thread safety issues? Q1) Is Spring controller inherently thread-safe?

My answer: By default, Spring controller is a Singleton bean. Whether it is inherently thread-safe or not depends upon how Singleton pattern is implemented by Spring. It can be done thread-safe or non-threadsafe. Correct?

Q2) Does Spring provide any annotation or configuration to ensure that handling multiple requests does not run into thread safety issues? Q3) Is ensuring thread safety the burden of the developer himself?

Praveen Nvs
  • 331
  • 3
  • 14

1 Answers1

-1

For your first question about how the Singleton pattern is implemented by Spring see this link:

How does the singleton Bean serve the concurrent request?

Spring concurrency: How does Spring bean Handle concurrency

How does Spring MVC handle multiple users

Willem
  • 992
  • 6
  • 13
  • -Can you try answering this question as well? https://stackoverflow.com/questions/56389404/what-happens-if-a-server-receives-more-requests-than-it-can-handle – Praveen Nvs Jun 01 '19 at 11:42