Introduction
這陣子在研究CompletableFuture時,剛好看到一篇Oracle關於CompletableFuture如何使用才能有好效能的投影片。我在這裡做了些整理,分享給大家;如果有理解有問題或不足的地方,希望大家可以幫忙更正或補充。本篇圖片都來自於Reference中的投影片。本篇說到五個重點,前四點我會分別說明;第五點如字面上所說,ThreadPool本來就要根據需求而去使用,這裡我不特別探討。
- Avoid transition task from one thread to another. It costs.
- Avoid blocking inside CompletableFuture chains. It costs.
- Carefully avoid transition task from one thread to another. It costs.
- It may be useful to build chain of actions before execution.
- Different ThreadPools show different performance.
Reference
- Asynchronous API with CompletableFuture - Performance Tips and Tricks PDF
- Asynchronous API with CompletableFuture - Performance Tips and Tricks YouTube
留言
張貼留言