Skip to content
Snippets Groups Projects
Commit 24a35660 authored by Pascal Muetschard's avatar Pascal Muetschard
Browse files

DCL is broken and should not be used.

Use the acceptable instance holder pattern as a replacement.

Change-Id: I2fb29edd48e00ac36a7fb0907a21ae5ca1d5163f
parent 51f38fb6
No related branches found
No related tags found
No related merge requests found
......@@ -9,3 +9,4 @@ android.net.rtp.AudioGroup
android.net.rtp.AudioStream
android.net.rtp.RtpStream
java.util.concurrent.ThreadLocalRandom
com.android.internal.jank.InteractionJankMonitor$InstanceHolder
......@@ -293,7 +293,10 @@ public class InteractionJankMonitor {
UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_CLEAR_ALL,
};
private static volatile InteractionJankMonitor sInstance;
private static class InstanceHolder {
public static final InteractionJankMonitor INSTANCE =
new InteractionJankMonitor(new HandlerThread(DEFAULT_WORKER_NAME));
}
private final DeviceConfig.OnPropertiesChangedListener mPropertiesChangedListener =
this::updateProperties;
......@@ -385,15 +388,7 @@ public class InteractionJankMonitor {
* @return instance of InteractionJankMonitor
*/
public static InteractionJankMonitor getInstance() {
// Use DCL here since this method might be invoked very often.
if (sInstance == null) {
synchronized (InteractionJankMonitor.class) {
if (sInstance == null) {
sInstance = new InteractionJankMonitor(new HandlerThread(DEFAULT_WORKER_NAME));
}
}
}
return sInstance;
return InstanceHolder.INSTANCE;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment