mutual exclusion using Hashtable of java

hi mate i have a global Hashtable in my class, and two thread A and B that work with her. A reads from HashTable and B write in Hashtable.. is there a problem of mutual exclusion ? i need to syncrhonize it or Hashtable class is safe ?


Hashtable is a thread-safe implementation of the Map interface.

In regular put and get operations you will be safe. However, when you will iterate on it in one thread and modify its contents from another thread, you will have ConcurrentModificationException issues. So, when iterating, make sure you iterate on a copy of the original Hashtable.

You should use ConcurrentHashMap instead, which is a much better/faster implementation of java.util.Map interface.

Need Your Help

Terminate function in jQuery

jquery asynchronous

Let's suppose that I have a container <div id="container"></div>, that I'd like to fill with dynamically generated elements from a $.post response.. Than suddenly, for some reason, I'd ...

Question How to invalidate/refresh the VS IDE designer for C#?

c# visual-studio-2008 ide refresh designer

I have CustomForm inherited from Form which implements a boolean property named Prop. The forms I'll be using will inherit from CustomForm. This property will do some painting and changes (if it's

Java: Get URI from FilePath

java url uri filepath

I've little knowledge of Java. I need to construct a string representation of an URI from FilePath(String) on windows. Sometimes the inputFilePath I get is: file:/C:/a.txt and sometimes it is: C:/a...