You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Java Concurrency
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,14 @@ how to use:
6
6
semaphore.acquire() // try to acquire the permit
7
7
semaphore.release()
8
8
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
+
9
17
[Notes from daily work]:
10
18
1. concurrent set allows concurrent iteration (In other words, it can safely iterate while other thread is attempting to modify this set)
0 commit comments