B
B
Biaci_Anj2021-07-08 18:18:20
Java
Biaci_Anj, 2021-07-08 18:18:20

Spring, why don't we use synchronize?

How does multithreading work in a Spring application? It uses servlets, a thread is created per user, so why don't errors occur?
Without a framework, we have to synchronize methods, but here we call methods of other classes from the controller without synchronize, why doesn’t the code break?
Silly question, I know, but I would be very grateful for the answer.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Roo, 2021-07-08
@Biaci_Anj

Multithreading works exactly the same.
synchronized is used whether you use any frameworks or not.
Multithreaded applications can be written without any locks at all, resolving access to resources by architectural decisions, using immutable types, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question