You should NOT call lock/unlock from within your update/delete methods! To update a record you should make 3 seperate calls to your Data class. Your update/delete methods should do what their names intend: just update or delete the record. Otherwise your design will be considered poor (each method should have its own specific responsability, remember
high cohesion). And you'll also be in trouble, because you won't be able to prevent double bookings that way.
A few scenarios and what should happen (in my opinion):
t1.lock(1);
t2.lock(1);
--> t2 should wait, no exception should be thrown
t1.lock(1);
t2.lock(2);
--> both threads should own lock on the record
t1.lock(1); // returns 100
t2.update(1, 100);
--> record should be updated
t1.lock(1); // returns 100
t2.update(1, 200);
--> SecurityException should be thrown (from update)
t1.update(1, 100);
--> SecurityException or
IllegalStateException should be thrown, based on your understanding of the instructions.