It throws java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextEntry(HashMap.java:762) at java.util.HashMap$KeyIterator.next(HashMap.java:798) at suncertify.server.RemoteAccess.unreferenced(RemoteAccess.java:298) at sun.rmi.transport.Target$1.run(Target.java:321) at java.lang.Thread.run(Thread.java:536) Could someone tell me why and how to handle it? Thanks!

I'm not positive that my solution will do it, but since HashMap is not thread safe, you need to synchronize the method or the code block. That way things will single-thread through and you should be ok. ms

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

Billy, the HashTable and Vector collections are Synchronized, the others are not. They are also considered older collection versions and SUN has made better versions of them. I know that is a quick and dirty way to explain why we like HashMap or ArrayList better. Mark