Hi Ray
Could someone tell me why
The exception you are getting is ConcurrentModificationException. Concurrent meaning "at the same time". The JVM is complaining that someone is modifying data at the same time that it is trying to work with it.
So you have an iterator stepping over the lockRecords collection. But at the same time, something is modifying them: your call to lockRecords.remove().
Does this explain why you are getting the exception?
and how to handle it?
Instead of iterating over your collection, perhaps you could make an array of the elements of that collection. Then you can walk through the array, removing items from the collection safely.
Alternatively, since this collection seems specific to this instance of the Remote object, you could just unlock all the records in the iterator, then once complete, just empty the collection in one hit. There doesnt seem to be a need to remove the individual records during the iteration.
Regards, Andrew