I am working on the design phase for the SCJD - B&S 2.1.1.
I just want to make sure that I understand something here and correct me if I am wrong.
There are two essential parts here:
1. Data Access: I usually planning on having some sort of an Access Manager that would handle data access tasks (I/O,DAO,DTO,..etc). That would make sure that multiple reads are possible and only one write for any record in the db file.
2. Locking Mechanism: That would make sure if a record is to be locked for booking or something like that, only the same client is able to unlock it .
Both of the above might be a combination of synchronized blocks and/or java.util.concurrent.locks. Is that correct ?
Yes, you have 2 parts in the Data class: the real data access (reads and writes to a file) and a locking mechanism which should prevent a thread from updating/deleting a record if it doesn't own the lock on that record.