MindMap Gallery Java concurrency
This is a mind map about Java concurrency. The main content includes: locks, thread pools, concurrent containers, and basic concepts.
Edited at 2024-04-22 19:41:17This is a panoramic infographic—currently sweeping across the web—illustrating the comprehensive applications of OpenClaw, a popular open-source AI agent platform. It systematically introduces this intelligent agent framework—affectionately dubbed "Lobster Farming"—helping readers quickly grasp its core value, technical features, application scenarios, and security protocols. It serves as an excellent introductory guide and practical manual.
這是一張最近風靡全網關於熱門開源AI代理平台OpenClaw的全網應用全景圖解。它系統性地介紹了這款被稱為「養龍蝦」的智慧體框架,幫助讀者快速理解其核心價值、技術特性、應用場景及安全規範,是一份極佳的入門指南與實操手冊。此圖主要針對希望利用AI建構自動化工作流程的技術從業人員、中小企業主及效率追求者,透過9大模組層層遞進,全面剖析了OpenClaw從概念到落地的整個過程。 圖中核心內容首先釐清了「養龍蝦」指涉的是OpenClawd開源智能體,並強調其本質是「AI基建」而非一般聊天機器人。隨後詳細比較其與傳統AI助理的區別,擁有記憶管理、權限控制、會話隔離和異常恢復四大基礎能力,支援跨平台存取和多模型相容(如GPT、Claude、Ollama)。同時,圖解提供了完整的部署方案(雲端/本地/Docker),並列舉了辦公室自動化、內容創作、資料收集等五大應用程式場景。此外,還展示了其火爆程度、政府與大廠佈局、安全部署建議及適合/不適合的人群分類。幫助你快速掌握OpenClaw技術架構與應用價值,指導個人或企業建構AI自動化系統,規避資料外洩與權限失控風險,是學習「執行式AI」轉型的權威參考圖譜。
本圖由萬興腦圖繪製,是針對IT研發崗位的結構化個人履歷模板,完整涵蓋求職核心資訊模組。基本資訊區包含姓名、電話、信箱、求職意願及GitHub連結;專業概要要求以2-3句提煉核心優勢;工作經驗以「公司A高級Java開發工程師」為例,以「透過(行動),達成(量化成果)」格式呈現微服務架構設計、系統效能優化、團隊技術規範制定等職責,公司B經歷則聚焦功能模組開發與Elasticsearch搜尋優化;技能專長分程式語言、後端框架、中介軟體、資料庫、容器雲等維度,清楚展示技術堆疊;專案成果以「電商平台秒殺系統」為例,說明技術棧、架構設計、個人貢獻(Redis Lua庫存原子扣減)及KPI;教育背景包含一流大學電腦專業學歷,以及AWS認證解決方案架構師、軟考中級軟體設計師證書。模板邏輯嚴謹,涵蓋IT研發求職全流程關鍵訊息,幫助求職者清晰、量化展示專業能力。
This is a panoramic infographic—currently sweeping across the web—illustrating the comprehensive applications of OpenClaw, a popular open-source AI agent platform. It systematically introduces this intelligent agent framework—affectionately dubbed "Lobster Farming"—helping readers quickly grasp its core value, technical features, application scenarios, and security protocols. It serves as an excellent introductory guide and practical manual.
這是一張最近風靡全網關於熱門開源AI代理平台OpenClaw的全網應用全景圖解。它系統性地介紹了這款被稱為「養龍蝦」的智慧體框架,幫助讀者快速理解其核心價值、技術特性、應用場景及安全規範,是一份極佳的入門指南與實操手冊。此圖主要針對希望利用AI建構自動化工作流程的技術從業人員、中小企業主及效率追求者,透過9大模組層層遞進,全面剖析了OpenClaw從概念到落地的整個過程。 圖中核心內容首先釐清了「養龍蝦」指涉的是OpenClawd開源智能體,並強調其本質是「AI基建」而非一般聊天機器人。隨後詳細比較其與傳統AI助理的區別,擁有記憶管理、權限控制、會話隔離和異常恢復四大基礎能力,支援跨平台存取和多模型相容(如GPT、Claude、Ollama)。同時,圖解提供了完整的部署方案(雲端/本地/Docker),並列舉了辦公室自動化、內容創作、資料收集等五大應用程式場景。此外,還展示了其火爆程度、政府與大廠佈局、安全部署建議及適合/不適合的人群分類。幫助你快速掌握OpenClaw技術架構與應用價值,指導個人或企業建構AI自動化系統,規避資料外洩與權限失控風險,是學習「執行式AI」轉型的權威參考圖譜。
本圖由萬興腦圖繪製,是針對IT研發崗位的結構化個人履歷模板,完整涵蓋求職核心資訊模組。基本資訊區包含姓名、電話、信箱、求職意願及GitHub連結;專業概要要求以2-3句提煉核心優勢;工作經驗以「公司A高級Java開發工程師」為例,以「透過(行動),達成(量化成果)」格式呈現微服務架構設計、系統效能優化、團隊技術規範制定等職責,公司B經歷則聚焦功能模組開發與Elasticsearch搜尋優化;技能專長分程式語言、後端框架、中介軟體、資料庫、容器雲等維度,清楚展示技術堆疊;專案成果以「電商平台秒殺系統」為例,說明技術棧、架構設計、個人貢獻(Redis Lua庫存原子扣減)及KPI;教育背景包含一流大學電腦專業學歷,以及AWS認證解決方案架構師、軟考中級軟體設計師證書。模板邏輯嚴謹,涵蓋IT研發求職全流程關鍵訊息,幫助求職者清晰、量化展示專業能力。
Java concurrency
basic concept
process
heap
method area
The heap and method area are resources shared by all threads. The heap is the largest piece of memory in the process and is mainly used to store newly created objects (almost all objects allocate memory here). The method area is mainly used to store loaded objects. Class information, constants, static variables, code compiled by just-in-time compiler and other data.
thread
program counter
Virtual machine stack
native method stack
There can be multiple threads in a process, and multiple threads share the heap and method area (metaspace after JDK1.8) resources of the process, but each thread has its own program counter, virtual machine stack and local method stack.
concurrent
parallel
Can easily lead to memory leaks, deadlocks, and thread insecurity
Synchronize
asynchronous
Thread safety
Create thread
Thread life cycle and status
NEW
Ready (Runnable)
Running
Blocked
Synchronous blocking (Blocked)
Waiting for blocking (WAITING)
Timeout waiting blocking (TMME-WAITING)
Death (Dead/TERMINATED)
Thread context switching
thread deadlock
Four necessary conditions for deadlock
How to prevent deadlock
How to troubleshoot
Graphical: jconsole
jps -l finds out the program process number, jstack process number
JMM
definition
background
CPU and cache coherence
Processor optimization
Parallel reordering of instructions
Compiler optimization rearrangement
Memory system rearrangement
Concurrency theory
as-if-serial rules
happens-before rule
program sequence rules
Monitor lock rules
Volatile variable rules
transitivity rule
start() rule
join() rules
Three major characteristics
atomicity
visibility
Orderliness
How to solve concurrency issues
Three major keywords
volatile
visibility
happens before principle
principle
write memory semantics
Read memory semantics
Orderliness
Implementation of memory semantics
synchronized
effect
atomicity
Orderliness
visibility
write memory semantics
Read memory semantics
Usage
Decorate instance methods
Modify static methods
Decorate code blocks
principle
synchronized code block
sync method
java object model
Object header
Mark Word
Klass Point
Instance data
Byte alignment
lock upgrade
no lock
Lock status
bias lock
Lock status
Upgrade time
Specific operations
benefit
The biased thread ID is inconsistent with the current thread ID.
Competition success
Competition failed
Technical realization
lightweight lock
Lock status
Upgrade time
effect
Spin
The difference between bias lock and bias lock
Heavyweight lock
Lock status
Upgrade time
principle
jdk1.6 optimization
spin lock
adaptive spin lock
lock elimination
lock roughening
bias lock
lightweight lock
final
effect
Reordering rules
Write reordering rules for final fields
Reordering rules for reading final fields
memory barrier
concurrent container
List
CopyOnWriteArrayList
Vector
Set
CopyOnWriteArraySet
Map
ConcurrentHashMap
ConcurrentSkipListMap
HashTable
queue
ArrayBlockingQueue
LinkedBlockingQueue
PriorityBlockingQueue
SynchronousQueue
Thread Pool
definition
Advantage
Reduce resource consumption
Improve response speed
Improve thread manageability
How to create
Executors
FixedThreadPool
SingleThreadExecutor
An unbounded LinkedBlockingQueue is probably used. The maximum length of the task queue is Integer.MAX_VALUE. A large number of requests may accumulate, resulting in OOM.
CachedThreadPool
The synchronization queue SynchronousQueue is used, and the number of threads allowed to be created is Integer.MAX_VALUE.
ScheduledThreadPool
The unbounded delayed blocking queue DelayedWorkQueue is used. The maximum length of the task queue is Integer.MAX_VALUE, which may accumulate a large number of requests, resulting in OOM.
ThreadPoolExecutor
Common parameters
corePoolSize
maximumPoolSize
workQueue
keepAliveTime
unit
threadFactory
handler
AbortPolicy
CallerRunsPolicy
DiscardPolicy
DiscardOldestPolicy
Process of handling tasks
How to set the size of the thread pool
Theoretical algorithm
empirical method
CPU intensive tasks (N 1)
I/O intensive tasks (2N)
Future class
Cancel task
Determine whether the task has been canceled
Determine whether the task has been completed
Get task execution results
shortcoming
CompletableFuture
Solve the shortcomings of Future
advantage
CompletionStage
Lock
basic concept
pessimistic lock
advantage
The cost of pessimistic locking is fixed
shortcoming
Fierce lock competition can cause thread blocking
A large number of blocked threads will cause context switching of the system Increase system performance overhead
Pessimistic locking may also cause deadlock problems
Applicable scene
Write multiple scenarios and fierce competition (to avoid frequent failures and retries that affect performance)
optimistic locking
advantage
There is no lock competition causing thread blocking
There will be no deadlock problem
shortcoming
If conflicts occur frequently (a lot of writes occur), there will be frequent failures and retries.
Applicable scene
Multiple reading scenarios, less competition (can avoid frequent locking affecting performance)
Implementation plan
Version number mechanism
CAS algorithm
ABA questions
Long cycle time and high overhead
Only atomic operations on a shared variable are guaranteed
ThreadLocal
effect
principle
Hash algorithm
Hash conflict
Memory leak problem
reason
solution
AQS
main idea
state
CLH queue
structure
principle
advantage
Excellent performance, low overhead for acquiring and releasing locks.
fair lock
Simple to implement and easy to understand
Strong scalability
shortcoming
Spin operation will cause large CPU overhead when the lock is held for a long time.
Single function and cannot support complex functions
CLH cohort variants
AQS changes spin operation to blocking thread operation
Improvements to lock data structures
Extend the state of each node
SIGNAL
PROPAGATE
CONDITION
CANCELLED
Explicitly maintain predecessor and successor nodes
Optimization of auxiliary GC such as explicitly setting the dequeue node to null
Schematic diagram
shared lock
exclusive lock
ReentrantLock
what is
principle
Unfair locking process
When thread one is locked successfully
AQS internal data
Thread two lock failed
CLH queue situation
Thread three lock failed
Fair lock locking process
Unlocking process
The process of releasing the lock
Waiting for queue data
final queue data
Condition
Implementation principle
ReentrantReadWriteLock
Applicable scene
Can a thread still acquire a write lock if it holds a read lock?
Read lock cannot be upgraded to write lock
Semaphore
Two modes
fair mode
Unfair model
principle
CountDownLatch
effect
principle
Disposable
CyclicBarrier
Atomic class
basic type
AtomicInteger
AtomicLong
AtomicBoolean
array type
AtomicIntegerArray
AtomicLongArray
AtomicReferenceArray
reference type
AtomicReference
AtomicStampedReference
Object property modification type
AtomicIntegerFieldUpdater
AtomicLongFieldUpdater
AtomicReferenceFieldUpdater