Re: synchronized HashMap vs. HashTable

Discussion in 'Java' started by Arne Vajhøj, May 21, 2008.

  1. Arne Vajhøj

    Arne Vajhøj Guest

    Mikhail Teterin wrote:
    > 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?


    Yes.

    Since December 1998 HashMap has been the recommended solution
    over Hashtable.

    Most developers will expect to see HashMap, so I would recommend
    using that - even though it does not have any real impact.

    Arne
     
    Arne Vajhøj, 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:
    132,061
    tonni
    Aug 11, 2010
  2. Pep
    Replies:
    6
    Views:
    29,369
  3. dmcreyno
    Replies:
    9
    Views:
    9,629
    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,296
    javabudy
    Jan 5, 2011
  5. Mark Space
    Replies:
    0
    Views:
    716
    Mark Space
    May 21, 2008
Loading...

Share This Page