Types in the Java Concurrency Utilities (APIs) are organized into small frameworks:
- Executor framework
- Synchronizers
- Concurrent collections
- Locks
- Atomic variables
- Fork/Join
- BlockingQueue
- BlockingDeque
- ConcurrentMap
BlockingQueue (put(NonNull e),take()) {ArrayBlockingQueue (bounded), LinkedBlockingQueue (unbounded), DelayQueue (unbounded), SynchronousQueue (unbounded), PriorityBlockingQueue, LinkedTransferQueue}
throws exception: add(e) remove() element()
special value: offer(e) poll() peek()
blocking methods: put(e) take()
times out: offer(e,longtime,unit) poll(longtime,unit)
method names: the names of methods of BlockingQueue+{First/Last}
put() = putLast() take() = takeFirst() element() = getFirst() peek() = peekFirst()
Segment = HashEntry[] Map = Segment[]
public V putIfAbsent(K key, V value) boolean remove(Object key, Object value) public V replace(K key, V value) public V replace(K key, V oldValue, V newValue)
ConcurrentNavigableMap (headMap(key), subMap(k1,k2), tailMap(key), navigableKeySet(), descendingMap(), descendingKeySet())
acquire() tryAcquire() acquireUninterruptibly()
Multiplayer scenario: Waiting for the last player to come in, to start gameplay.
- await()
- countDown()
- CyclicBarrier(int nThreads)
- CyclicBarrier(int nThreads, Runnable barrierAction)
- await()
- reset()
a bidirectional form of SynchronousQueue
- exchange(Object o) this.object = this.exchanger.exchange(this.object); // in a participating thread
-
phase number
-
dynamic number of unarrived parties
-
register()
-
onAdvance()
-
arriveAndAwaitAdvance()
-
arriveAndDeregister()
-
isTerminated()