java concurrent programming notes

synchronized

lock object

on method = lock this object

On static method = lock class object

An exception occurs, the lock will be released

The lock is the heap object, not the stack reference

Don't use String objects for locking

dirty read

The business write method is locked and the read method is not locked, which is prone to dirty reads

volatile

Guaranteed visibility, not atomicity

use of wait notify

countDownlatch latch usage

Lock

ReentranLock use

Producer Consumer Model

The reason why wait is used with while the reason for notifyAll

Lock的condition await signalAll

ThreadLocal

Map

Hashtable hashmap concurrentHashMap

Ordered: TreeMap concurrentskiplistMap

List

Arraylist linkedlist Vector CopyOnWriteArrayList

collections.synchronizedXXX lock collections

Queue

concurrentLinkedqueue

Concurrent locking

Put the poll head at the end of the offer, take it and delete the peek head, take it and not delete it

BlockingQueue

blocking

Put is full, waiting for take is empty, waiting for the production and consumption mode that comes with java

linkedBlockingQueue unbounded

arrayBlockingQueue有界 

TransferQueue

SynchronusQueue

add offer put difference

add full error

If the offer is full, no error will be reported and return false

put full waiting

DelayQueue executes timed tasks

Concurrency framework

disruptor netty

 

Thread Pool

Executor

ExecutorService

Callable&runable区别

Callable has return runable has no return

Executors

 

future

 

threadpool

fixed

cached

single

scheduled

workstealing

forkjoin

threadpoolExecutor

parallelstreamapi

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326112393&siteId=291194637