Java 并发

Wrap Elasticsearch Response Into CompletableFuture

Wrap Elasticsearch client response into CompletableFuture in Java for Elasticsearch transport client or Java high level REST client.

26 Jul 2020

Why Do We Need Completable Future?

Why do we need CompletableFuture? What is its strength compared to synchronous code and classic future in Java? How to remember its APIs?

26 Jun 2020

Write An Actor In Akka

How to write a new actor in Akka in Java? This post explains actor creation, message reception, and testing.

20 Jun 2020

3 Ways to Handle Exception In Completable Future

How to handle exception in CompletableFuture? This article explains the difference between handle(), whenComplete(), and exceptionally().

30 May 2020

How CompletableFuture is tested in OpenJDK?

How CompletableFuture is tested in OpenJDK 14? What can we learn from it?

10 May 2020

Asynchronous Processing in JAX-RS 2.x

Quick introduction of asynchrnous processing in JAX-RS 2.x on both server-side and client-side.

15 Mar 2020

Akka: Testing Actor with TestActorRef

Unit testing Akka actor with "TestActorRef", which gives you access to underlying actor instance and runs the logic synchronously in a single-threaded environment.

08 Jan 2020


Using 100% CPU effortlessly in Java: submit all your tasks to thread pool and wait for completion.

29 Jan 2019

Method Execution In Multithreading

Today I met some multithreading problems. Many Java syntax become very confusing in a multithreading environment. So I created a mini Java program, and wrote this study note to clarify the unclear methods. This blog post will go through the following steps:

  1. Source code and execution
  2. Understand Thread#join()
  3. Understand logic sharing
  4. Understand variable sharing

01 Jul 2018

Introduction to Threads

Today, I want to share with you an introduction to multithreading in Java. In order to make the blog post more fun, I'll use the roles of "Game of Thrones" in my examples: white walkers and the Night King. After reading the blog post, you'll understand: How to create and run a thread, use wait(), notify(), notifyAll() and join().

05 Nov 2017