Java Performance Tuning
Java(TM) - see bottom of page
Our valued sponsors who help make this site possible
JProfiler: Get rid of your performance problems and memory leaks!
Training online: Concurrency, Threading, GC, Advanced Java and more ...
News November 2017
JProfiler
|
Get rid of your performance problems and memory leaks!
|
JProfiler
|
Get rid of your performance problems and memory leaks!
|
|
|
Back to newsletter 204 contents
Long time reader Brent Boyer points out that my point "if you have
done all the updating of the HashMap in a single thread or synchronized,
then after that it's safe to access it from multiple threads (if they
have the view of the map after updating has finished)" from
September's
newsletter is specific to the existing HashMap implementation; another
(future) implementation could perfectly reasonably mutate the map on reads,
with Brent giving a desired example of a self-adapting HashMap that changes
its internal structure to optimize the read pattern it is being used with,
as it monitors those reads.
And of course that's quite true. I wasn't saying that you SHOULD do
that with HashMap. If you have a concurrent use for a hashed based map
you should definitely use ConcurrentHashMap, and indeed I recommend (as
I did last August) that you actually use ConcurrentHashMap as your
default map implementation so that maintenance changes are handled
correctly.
My point in September's newsletter was about maintenance and could be
misconstrued so let me be more accurate:
- Use thread-safe structures where concurrent access/update can happen
- Concurrency do-it-yourself is really hard to get right, try to find
a mature thread-safe structure that does it for you (even if that means
you have to adapt your flow to use that)
- If you really do need to build thread-safety yourself, do it in an
encapsulated way, eg with all the multi-threaded management of access
and updates to your data structures hidden behind class APIs so that
fixes can be applied internally with no need for the external users
to have to change their usage
Now on to our usual links to articles, tools, news, talks, blogs. And
if you need the tips from this month's articles and talks, as ever
they are extracted into
this month's tips page.
A note from this newsletter's sponsor
JProfiler
Get rid of your performance problems and memory leaks!
News
Java performance tuning related news.
Tools
Java performance tuning related tools.
Articles
Jack Shirazi
Back to newsletter 204 contents
Last Updated: 2024-11-29
Copyright © 2000-2024 Fasterj.com. All Rights Reserved.
All trademarks and registered trademarks appearing on JavaPerformanceTuning.com are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries. JavaPerformanceTuning.com is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
URL: http://www.JavaPerformanceTuning.com/news/news204.shtml
RSS Feed: http://www.JavaPerformanceTuning.com/newsletters.rss
Trouble with this page? Please contact us