In the common DBMS, the read/write operation has been implemented the Lock-system implicitly so that programmer does not necessarily handle this complex locking mechanism. But why when we write code on the application level, it is common that we still need to use some lock/synchronized function when doing write.
e.g.
public synchronized writetoDBMS(){
SQL statement writing to DBMS }
@Kit Ho: synchronized keyword before method name just ensures only single thread is executing at a time the enclosed code and also other synchronized methods of same object…so other operations can be read or write operation.
Now why do you see synchronized keyword on some DB related methods?
well for concurrent operations to be handled by Database, you rely isolation level.Read
Database Isolation
Now let us say your DB isolation level is READ UNCOMMITTED and you have methods doing read and write to same table, then u definitely want to synchronize those methods.