I am learning about the isolation levels at db. I have a doubt, for example with JAVA if we made sure that only one thread can make db update/create call at a time with synchronised block and methods, do we need to enforce isolation levels at db? similarly, if we have serialisable isolation at db do we need to make threads synchronised?
Consider a booking system. How do we make sure that no two people to book the same.
CodePudding user response:
With databases, you can have connections from different processes on the same machine or even from different machines.
Because a synchronized block only has meaning in a single process, a synchronized block doesn't work with multiple processes from the same machine and therefore also not from processes of different machines.
So a synchronized block is not a replacement for database isolation levels.