mirror of
https://github.com/github/codeql.git
synced 2026-05-01 11:45:14 +02:00
Java: Add 2 double-checked-locking queries.
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
private Object lock = new Object();
|
||||
private MyObject f = null;
|
||||
|
||||
public MyObject getMyObject() {
|
||||
if (f == null) {
|
||||
synchronized(lock) {
|
||||
if (f == null) {
|
||||
f = new MyObject(); // BAD
|
||||
}
|
||||
}
|
||||
}
|
||||
return f;
|
||||
}
|
||||
Reference in New Issue
Block a user