Your question is not very specific, I'll try to answer it based on what you mentioned most (DDD and DAL).
There is concurrency control at the request
level, that is, concurrent requests have their own memory as a sandbox, they do not share most states. An example of an object that is split is session.
As you spoke more with a focus on DDD and data access (I imagine it is the bank), you have to take control.
Suppose you are using EntityFramework
, you can have concurrent requests on the same data, and that can be a problem.
Example: a reservation system, where user A can be with the seating window open, thinking where to sit. Meanwhile, user B also arrives on that screen and chooses seat 1. Coincidentally, user A also chooses seat 1 and triggers the request along with user B, so that the 2 requests arrive on the server together. At that time, if your code does not handle competition and simply run User.MakeReservation(1)
for both users, you will lose data.
There are several ways to deal with this, such as pessimistic and optimistic competition.
At the thread level and everything else, each request will most often have its space, and within that space you have to deal with competitions of that type.