Hi Mark
In the requirements does it have the signature of lock to throw an InterruptedException? I'd suggest placing a try catch in the lock method aounr the wait() call, then catch the Interrupted Exception there, and outside the while do your add() and remove the notifyAll().
I removed the InterruptedException in the method signature, I have used a try-catch and that solved all the problem. Now the booking is working perfectly. Thank you very much.
Why do I need to remove the notifyAll since after locking a record the waiting threads must be notified that the dbLock is free?
And what happens in the unlock method if by accident a record number is passed that is not locked?
To address this issue I have slightly modified the code to remove the lock on a record only after a check as given:
I hope this should fix the issue.
Thanks
Ravi
SCJP, SCJD, SCWCD, SCBCD, SCEA