0

here I want to ask about the concept of threads in spring boot. what I've read, if there are 5 api calls by 5 users simultaneously then spring boot will also automatically create 5 threads to respond to those 5 calls. or it will respond to the api call only with the main thread because we don't set spring boot using async thread. is it really like that? Thank you

1 Answers1

0

Yes, that's the classic approach how requests are handled.

For example, when using the embedded Tomcat, you can define the maximum amount of threads to handle client requests: https://stackoverflow.com/a/25401832/2310221

That said, there are approaches that work differently, for example reactive programming with Spring Reactor:

Project Reactor is a fully non-blocking foundation with back-pressure support included

Markus
  • 1,649
  • 1
  • 22
  • 41
  • can we make like thread inside thread in spring boot completable future. example when we have productController and have several services like CRUD. when user hit api create from productController. then 2 thread are running. first from the parent ( productController) then second thread in create method. – Adam Abdullah Dec 01 '22 at 10:46