5

Am I correct in saying that a .Net Hashtable is not synchronized while a Java Hashtable is? And at the same time a Java HashMap is not synchronized and has better performance?

I am rewriting a Java app that makes heavy use of HashMaps in C# and I would like to use a HashTable and ensure that the performance is basically equivalent.

1
  • Your question is somewhat unclear about what your goals are in asking this question. Please consider revising a bit so it's more clear what you're hoping to learn exactly. Commented Jul 31, 2009 at 1:14

2 Answers 2

6

I think what you're asking is if HashMaps in Java and HashTables in C# act in roughly the same way and you're largely correct from a performance point of view. HashMaps as I recall do not complain if you insert duplicate keys whereas HashTable in C# will.

Sign up to request clarification or add additional context in comments.

Comments

0

By default, .NET Hashtables are not synchronized, but you can create a synchronized wrapper around one, like so:

Hashtable myHash = Hashtable.Synchronized(new Hashtable());

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.