Skip to main content
Yujie's blog
My Knowledge Base
Catelog
Computer Basic
Data Scructure and Algotithm
Frontend
Network
Backend
OOP & Java
Springboot Fromework
DevOps & MidWare
MySQL
Redis
Nacos
HPC
CUDA Tutorial
OpenMPI
Projects
Thesis projects
[BSc] Help Rich Info Get Richer
[MSc] Testing and Mutation Testing on GPU kernels
Campus projects
Stryker Cloud Agent
Cloud Cost Optimisation (Ideas)
Syncnema (SoA Course Project)
Personal projects
YJ Music Player
API Monitor
Life
About My Life
Diaries
Essays
Ideas
Life Manual
My Life Manual
Study Mode
线程安全如何实现
Yujie Liu
Less than 1 minute
Computer Science
Programming Language
Java
#
线程安全如何实现
线程安全问题的产生本质上是因为多个线程在并发条件下对同一个共享资源的争抢,因此有两种方向来保证线程安全:
限制线程对资源的并发访问:这个方向的主要方式是加锁(阻塞),volatile(非阻塞)。
将该资源设置为线程独占的:这个方向主要实现方式是TreadLocal。
Prev
《Java Concurrency Intro 多线程入门》
Next
《Java Lock Intro 锁入门》