|
|
|
Back to newsletter 170 contents
I love the fascinating new items my newsletters teach or remind me. In this month's extracted tips from the linked articles I learned:
1. You can back any (ExecutorService) thread pool with a SynchronousQueue which makes it queueless (it only accepts a task if there is a free thread);
2. You can use AtomicIntegerFieldUpdater for lazily atomically updating volatiles (volatile++ is not atomic, AtomicIntegerFieldUpdater.getAndIncrement(object) is);
3. All Java 8 parallel streams across the JVM globally share the same thread pool by default - I can immediately see this is something that will cause contention issues in the future, so you should know it so it's easily diagnosed.
4. I've used the following statement every time I look at a heap dump, but funnily enough I've never seen it written down in this concise way: When there is a large difference in retained memory between a parent and child object, this is a good candidate for the holder of a memory leak.
5. Change the thread name to show the resources and data context it is operating in so that if you take a trace using jstack, you get the context as well as the operating stack - this makes diagnosing what it is doing much easier (you can keep changing the thread name, though it's probably not useful to change it too often).
6. Cancelling running tasks asynchronously is hard - you need to think about how that can happen if your task is in a non-interruptible call like using a resource (often that requires another thread closing that resource so that the task can exit the call and terminate).
Now on to all our usual sections: links to tools, articles, news, talks and as ever, all the extracted tips from all of this month's referenced articles including those gems above.
Java performance tuning related news.
Java performance tuning related tools.
Back to newsletter 170 contents