I am so confused on this issue. My assignment DB interface something look like this:
public
String[] read(int recNo) throws RecordNotFoundException;
// Modifies the fields of a record. The new value for field n
// appears in data[n]. Throws SecurityException
// if the record is locked with a cookie other than lockCookie.
public void update(int recNo, String[] data, long lockCookie)
throws RecordNotFoundException, SecurityException;
// Deletes a record, making the record number and associated disk
// storage available for reuse.
// Throws SecurityException if the record is locked with a cookie
// other than lockCookie.
public void delete(int recNo, long lockCookie)
throws RecordNotFoundException, SecurityException;
As you see when performing lock record, a lockCookie is needed. Does that mean that if I use lockCookie to control lock, I don't need synchronized to lock the object? Advice please. I am so confused them. Am i supposed to use both of just either of them?
Thanks!