Re: synchronized HashMap vs. HashTable

Discussion in 'Java' started by Mark Space, May 21, 2008.

  1. Mark Space

    Mark Space Guest

    Mikhail Teterin wrote:
    > Hello!
    >
    > I need multiple threads to be able to operate on the same Map. The HashMap's
    > documentation at
    >
    > http://java.sun.com/javase/6/docs/api/java/util/HashMap.html
    >
    > advises the following construct:
    >
    > Map m = Collections.synchronizedMap(new HashMap(...));
    >
    > However, the HashTable is, supposedly, inherently thread-safe.
    >
    > What's better? I saw somewhere, that HashTable is a "legacy" class -- is
    > that true?


    Kind of, yes, although I don't think HashTable is actually deprecated.
    It's a situation where you have to understand the trade-offs.

    Also look at this:

    <http://java.sun.com/docs/books/tutorial/essential/concurrency/collections.html>
    Mark Space, May 21, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jerry
    Replies:
    4
    Views:
    131,812
    tonni
    Aug 11, 2010
  2. Pep
    Replies:
    6
    Views:
    29,262
  3. dmcreyno
    Replies:
    9
    Views:
    9,559
    Mark Space
    Jun 27, 2006
  4. Knute Johnson

    Re: synchronized HashMap vs. HashTable

    Knute Johnson, May 21, 2008, in forum: Java
    Replies:
    9
    Views:
    3,233
    javabudy
    Jan 5, 2011
  5. Arne Vajhøj
    Replies:
    0
    Views:
    448
    Arne Vajhøj
    May 21, 2008
Loading...

Share This Page