Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Java in General
Do we have to keep call to HashMap synchronized as hashmap is not synchronized like hashtable
Monica Shiralkar
Ranch Hand
Posts: 2925
13
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Do we have to keep code calling the HashMap synchronized as hashmap is not synchronized like hashtable?
thanks.
Campbell Ritchie
Marshal
Posts: 79177
377
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
No. You create a synchronised Map. It should tell you in the documentation for HashMap(←link) how to do it.
Monica Shiralkar
Ranch Hand
Posts: 2925
13
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks. So if we either use Hash Map or synchrnonized HashMap then there is no case left where we would prefer Hash Table because even if synchronization is needed we use synchronized Hash Map.
Rob Spoor
Sheriff
Posts: 22783
131
I like...
posted 8 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I would instead prefer ConcurrentHashMap.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions
How To Answer Questions
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Using Properties instead of HashMap when dealing with Strings
synchronize in Collections not in Threads in Core Java
Will storing a HashMap inside a Hashtable make the HashMap threadsafe?
Locking problem
Hashtable vs HashMap
More...