File tree 1 file changed +7
-22
lines changed
modules/siddhi-core/src/main/java/org/wso2/siddhi/core/util
1 file changed +7
-22
lines changed Original file line number Diff line number Diff line change 18
18
19
19
package org .wso2 .siddhi .core .util ;
20
20
21
- import java .util .concurrent .locks .Lock ;
22
21
import java .util .concurrent .locks .ReentrantLock ;
23
22
24
23
public class ThreadBarrier {
25
24
26
- private volatile Lock lock = null ;
25
+ private ReentrantLock lock = new ReentrantLock () ;
27
26
28
27
public void pass () {
29
- if (lock != null ) {
30
- synchronized (this ) {
31
- if (lock != null ) {
32
- lock .lock ();
33
- lock .unlock ();
34
- }
35
- }
28
+ if (lock .isLocked ()) {
29
+ lock .lock ();
30
+ lock .unlock ();
36
31
}
37
32
}
38
33
39
- public synchronized void lock () {
40
- if (lock == null ) {
41
- lock = new ReentrantLock ();
42
- }
34
+ public void lock () {
43
35
lock .lock ();
44
-
45
36
}
46
37
47
- public synchronized void unlock () {
48
- if (lock != null ) {
49
- try {
50
- } finally {
51
- lock .unlock ();
52
- }
53
- lock = null ;
54
- }
38
+ public void unlock () {
39
+ lock .unlock ();
55
40
}
56
41
57
42
}
You can’t perform that action at this time.
0 commit comments