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

Are there shortcut keys for ReSharper's Unit Test Runner?

unit-testing keyboard-shortcuts resharper command

For obvious productivity reasons, I make an effort of learning and using as many of the keyboard shortcuts for the various Re# commands.

NSPersistentStoreCoordinator not created on a UIManagedDocument

core-data icloud uimanageddocument nspersistentstore

I'm starting to learn about UIManagedDocument and its abilities. From what I understand of it its a form of database stored in a location in the documents directory.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.