Skip to content

Commit e4bf312

Browse files
authored
Update Java Concurrency
1 parent 3ad6205 commit e4bf312

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Java Concurrency

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ how to use:
66
semaphore.acquire() // try to acquire the permit
77
semaphore.release()
88

9+
Conditional Variable:
10+
Lock lock = new ReentrantLock();
11+
Condition condVar = lock.newCondition();
12+
13+
14+
signalAll() is a method specific to a Condition, whereas notifyAll() is done on any object you're locking on.
15+
signalAll() should be used when you're waiting/sleeping with Condition.await(), and notifyAll() when you're using Object.wait() inside a synchronized block.
16+
917
[Notes from daily work]:
1018
1. concurrent set allows concurrent iteration (In other words, it can safely iterate while other thread is attempting to modify this set)
1119

0 commit comments

Comments
 (0)