RSS feed [root] /weblog /java



title search:


Thu Apr 06 06:33:22 GMT 2023


(google search) (amazon search)
download zip of files only

Wed Sep 06 13:46:21 GMT 2023 From /weblog/java/concurrency


An API to get the state of a thread, but someone say it is not reliable -[..]5.0/docs/api/java/lang/Thread.State.html[..]readed-programs-tf3627394.html#a10128844

Having said that, I have to note that using Thread#getState() is not
something you can absolutely rely on as the behavior isn't guaranteed
to be the same on all platforms. That is, it can be a useful tool for
debugging and test-driving but not ideal for regression (unit)

Overview of Java thread -[..]t-thread-and-javalangthread-in-java.html

Loom -

How will we debug Loom applications? -[..]drv/how_will_we_debug_loom_applications/

Question: Why exactly are fibers cheaper than platform threads? -[..]ion_why_exactly_are_fibers_cheaper_than/

Handling Virtual Threads -

1. Avoid Synchronized Blocks/Methods
2. Avoid Thread Pools To Limit Resource Access
3. Reduce ThreadLocal Usage[..]o-avoid-when-switching-to-virtual-thread

Exploring the design of Java’s new virtual threads -

(google search) (amazon search)

Sat Jul 01 14:23:08 GMT 2023 From /weblog/java/performance


Another blog of discussion of difference profiler -

Introduction to jmap, visualvm and btrace -

JMP is an easy to setup and provide real time data choice. However it will crash JVM occasionally. So may be the one using web interface is better for us:

Articles -
Onjava -
Eclipsecolorer profiler, however that plugin require you install binary yourself, somehow tedious if you move from one machine to another machine -[..]tss?l=EclipseProfiler&asrc=EM_NLN_476666

A total java version of profiler!!:

Few other profiler haven't get time to try:

Eclipse plugin:

Need $$:

See if the information useful.

How to measure with less than milli second -[..]15/10/measuring-microsecond-in-java.html

Unleash the Power of Open Source Java Profilers: Comparing VisualVM, JMC, and async-profiler -

(google search) (amazon search)

Thu May 04 12:27:29 GMT 2023 From /weblog/java/features


List the pros of using native agent -[..]-for-application-performance-management/

Writing a Profiler in 240 Lines of Pure Java -[..]ng-a-profiler-in-240-lines-of-pure-java/

(google search) (amazon search)

Fri Apr 21 23:07:50 GMT 2023 From /weblog/java/features


Introduction to Java Encryption/Decryption -

Java Serialization Filtering: Prevent 0-day Security Vulnerabilities -[..]g-prevent-0-day-security-vulnerabilities

Using JCE with OpenSSL -[..]ive/src/java/jce-openssl-redux.writeback

---------- Forwarded message ----------
From: "cab"
Date: 10 Mar 2005 23:33:16 +0800
Subject: Re: CRC-32 crc32 = new;
long crcValue = crc32.getValue();

"Day Chan" 撰寫於郵件新聞:4230a15b$
> Does anyone know how to calculate CRC-32 in Java?
> Thanks~

(google search) (amazon search)

Thu Apr 20 13:08:46 GMT 2023 From /weblog/java/performance


Will you get any performance improvement if you manage memory yourself? -[..]ne-is-faster-java-heap-or-native-memory/

More heap, GC will get slower -[..]ing-heap-size-beware-of-the-cobra-effect

Collection of tools to analysis GC activities -

Another presentation of performance hint for hotspot or memory -

Show how to enable and analyze the verbose:gc out data -[..]3/01/java-verbose-gc-tutorial-video.html

Discussion and comparison of difference GC at Java 1.7 -[..]7/java-garbage-collection-distilled.html . And here is the detail experiment among those difference GC, look like G1 is quite promising -[..]ng-and-benchmarking-java-7s-garbage.html

Memory is not allocate to single block, thus even you allocate enough memory in term of size, it may not enough to held individual object -

Introduction to metaspace -[..]optimising-memory-consumption-first.html

Some comments about System.gc() -[..]om/2015/12/why-i-dont-like-systemgc.html[..]ng-your-java-garbage-collection-overhead

Logging stop-the-world pauses in JVM -[..]log/logging-stop-the-world-pauses-in-jvm

Why we should put difference app in same VM -[..]0/generational-disparity-in-garbage.html

Atlassian GC tuning guide -[..]ollection-gc-tuning-guide-461504616.html

Using jemalloc to get to the bottom of a memory leak -[..]c-to-get-to-the-bottom-of-a-memory-leak/

Troubleshooting-Java-Memory-Issues -

Useful parameters for OOME -

Why Java's TLABs are so important and why write contention is a performance killer in multicore environments -

MMU gang wars: the TLB drive-by shootdown -

Latency implications of virtual memory -

foreign-memaccess -[..]cimadamore/panama/foreign-memaccess.html

Detect proactively whether application’s memory is under-allocated -

Panama: Not-so-Foreign Memory. Using MemorySegment as a high-performance ByteBuffer replacement without a 2GB limit. -[..]soforeign_memory_using_memorysegment_as/

What’s the deal with humongous objects in Java? -[..]-the-deal-with-humongous-objects-in-java

Netflix on Java: How to build a 1TB Non-Heap, ultra-efficient application for video streaming - an example -[..]on-heap-application-for-video-streaming/

(google search) (amazon search)

Sat Mar 18 12:52:17 GMT 2023 From /weblog/java/network


一文带你掌握物联网 Mqtt 网关搭建背后的技术原理 -

(google search) (amazon search)

Wed Mar 08 12:44:43 GMT 2023 From /weblog/java/concurrency


There is a little bit performance cost for threadlocal variable -[..]ost-of-accessing-thread-local-variables/

Look like a useful but less known API -

Forward up discussion -[..]d_id=41473&asrc=EM_NNL_406677&uid=703565 pointing out some problems of using this technique, include similar effect of GLOBLE , possible memory leak

Another discussion in higher level -[..]04/thread-local-a-convenient-abomination , Key is "An object is an abstraction of function. A thread is an abstraction of schedule" , you can read further conclusion at

Protential issue of using threadlocal, one is memory leak and the other is it is that local -[..]hreading-stories-threadlocal-in-web.html[..]shoot-yourself-in-foot-with-threadlocals

The beauty of the design of threadlocal, how it prevent locking and memory leaking -

JEP 429: Extent-Local Variables to Promote Immutability in Java -

An Introduction to Scoped Values in Java -

(google search) (amazon search)

Wed Mar 08 12:41:52 GMT 2023 From /weblog/java/performance


Debugging RAM: Java Garbage Collection - Java Heap Deep Dive, Part 1 -[..]ge-collection-java-heap-deep-dive-part-1

Concurrent Marking in G1 -

What Should I Know About Garbage Collection as a Java Developer? -[..]t-garbage-collection-as-a-java-developer

(google search) (amazon search)

Wed Mar 08 12:38:40 GMT 2023 From /weblog/java/features


The Beauty of Java Optional and Either -

(google search) (amazon search)

Fri Feb 17 11:55:07 GMT 2023 From /weblog/java/features


Autoboxing, Type can be changed -

Project Valhalla: A look inside Java’s epic refactor -[..]a-a-look-inside-javas-epic-refactor.html

(google search) (amazon search)

Wed Feb 15 13:22:38 GMT 2023 From /weblog/java/tools


How to use Eclipse Memory Analyzer -[..]s-for-using-the-eclipse-memory-analyzer/

Tool to check java memory layout, how the object placed in JVM -

Question: How do you handle oversized heap analysis? -[..]w_do_you_handle_oversized_heap_analysis/

JVM Field Guide: Memory -

(google search) (amazon search)

Wed Feb 08 13:19:36 GMT 2023 From /weblog/java/features


Structured Concurrency and Loom -[..]ss/en/informatique/java-19-quoi-de-neuf/

Using Pattern Matching -

(google search) (amazon search)

Sat Dec 10 12:45:08 GMT 2022 From /weblog/java/features


FizzBuzz – SIMD Style! -

SIMD accelerated sorting in Java - how it works and why it was 3x faster -

(google search) (amazon search)

Tue Aug 02 13:15:30 GMT 2022 From /weblog/java/libraries


Kotlin DataFrame Preview -[..]022/06/kotlin-dataframe-library-preview/

(google search) (amazon search)

Tue Aug 02 12:39:29 GMT 2022 From /weblog/java/fundamental


Things I didn't know about Java: Generic Constructors -

(google search) (amazon search)

Wed Jul 06 13:31:29 GMT 2022 From /weblog/java/features


Strategies of loading image, select difference API to load image in difference case -[..]rticles/Media/imagestrategies/index.html

The Perils of Image.getScaledInstance() , with more detail explanation of image handling -[..]3/perils-of-image-getscaledinstance.html

In Part I we talk about the building blocks of metadata in images and how it may matter to you as developer. -

(google search) (amazon search)

Sun May 22 12:36:05 GMT 2022 From /weblog/java/fundamental


Data in Java programs - a basic conceptual model -[..]TscD4uW2Qsbt5BlBR_7uX_BekwJ5BLSE/preview

(google search) (amazon search)

Tue May 03 14:08:30 GMT 2022 From /weblog/java/hacks


Hint to prevent blocking of loadClass by using Thread.getContextClassLoader() -[..]3/java-class-loading-performance-impact/

(google search) (amazon search)

Mon Apr 25 00:31:35 GMT 2022 From /weblog/java/performance


Performance comparison for various implementation -[..]-sachs-hppc-koloboke-trove-january-2015/

Java Hashtable, HashMap, ConcurrentHashMap – Performance impact -[..]ap-concurrenthashmap-performance-impact/

Using Red-Black tree in Map -[..]shmaps-keys-and-the-comparable-interface

(google search) (amazon search)

Fri Apr 15 12:54:04 GMT 2022 From /weblog/java/network


1,000,000 Concurrent Connections -

(google search) (amazon search)

Tue Mar 29 05:28:14 GMT 2022 From /weblog/java/fundamental


JVM Anatomy Quark #26: Identity Hash Code -

Hash, displace, and compress: Perfect hashing with Java -

(google search) (amazon search)

Sat Mar 19 12:00:19 GMT 2022 From /weblog/java/concurrency


Just know that interrupt() call is just setting a flag, it have to be doing IO work (like database call), or in wait() status, before the thread can really be interrupted.[..]winger?entry=swingworker_stop_that_train

Another nice explanation about interrupt, in summary:

What should we do when we call code that may cause an InterruptedException? Don't immediately yank out the batteries! Typically there are two answers to that question:
1) Rethrow the InterruptedException from your method. This is usually the easiest and best approach. It is used by the new java.util.concurrent.* package [[..]util/concurrent/Semaphore.html#acquire() ], which explains why we are now constantly coming into contact with this exception.
2) Catch it, set interrupted status, return. If you are running in a loop that calls code which may cause the exception, you should set the status back to being interrupted. For example:
while (!Thread.currentThread().isInterrupted()) {
// do something
try {
} catch (InterruptedException e) {
Remember the Law of the Sabotaged Doorbell - don't just ignore interruptions, manage them properly!


Another blog explain about InterruptedException -[..]terruptedexception-and-interrupting.html[..]running-infinite-java-regular-expression[..]derstanding-thread-interruption-in-java/

How to Stop a Java Thread Without Using Thread.stop()? -[..]a-java-thread-without-using-thread-stop/

(google search) (amazon search)

Sat Feb 12 14:08:30 GMT 2022 From /weblog/java/features


Introduction of Lambdas expression in Java - , an example show how lambdas help to clean up the duplication -[..]mplifying-readwritelock-with-java-8.html

Another article about Java8 change, where Lambdas is the highlight -

Nice tutorial -

Huge list of articles -

Use lambdas to replace for-loop -[..]creating-your-own-loop-structure-in.html

Overview for new Date/Time library -[..]/02/java-date-time-timezone-formats.html[..]om/2014/05/java-8-features-tutorial.html

Grouping and partitioning with stream -[..]/11/java-8-streams-api-grouping-and.html
In a nutshell, make sure to never override a default method in another interface -[..]va-8-default-methods-can-break-your.html

Convert SQL feature to stream -[..]and-their-equivalents-in-java-8-streams/

Simple overview of steam operation -[..]va-8-stream-intermediate-operations.html

Behind the scenes: How do lambda expressions really work in Java? -[..]o-lambda-expressions-really-work-in-java

Useful & Unknown Java Features -[..]2022/01/05/useful-unknown-java-features/

(google search) (amazon search)