synchronized
锁定对象
在方法上=锁定this对象
static方法上=锁定class对象
出现异常,锁会被释放
锁定的是堆对象,不是栈引用
不要用String对象进行锁
脏读
业务写方法加锁 读方法不加锁 容易产生脏读
volatile
保证可见性,不保证原子性
wait notify使用
countDownlatch门栓使用
Lock
ReentranLock使用
生产者消费者模型
wait跟while一起用的原因 notifyAll的原因
Lock的condition await signalAll
ThreadLocal
Map
Hashtable hashmap concurrentHashMap
有序:TreeMap concurrentskiplistMap
List
Arraylist linkedlist Vector CopyOnWriteArrayList
collections.synchronizedXXX 加锁集合
Queue
concurrentLinkedqueue
并发加锁
offer尾部放 poll头部拿了删 peek头部拿了不删
BlockingQueue
阻塞式
put 满了等待 take空了等待 java自带的生产消费模式
linkedBlockingQueue无界
arrayBlockingQueue有界
TransferQueue
SynchronusQueue
add offer put 区别
add 满了报错
offer 满了不报错 返回false
put 满了等待
DelayQueue执行定时任务
并发框架
disruptor netty
线程池
Executor
ExecutorService
Callable&runable区别
Callable有返回 runable无返回
Executors
future
threadpool
fixed
cached
single
scheduled
workstealing
forkjoin