Skip to content

Commit

Permalink
double checked locking for getInstance method
Browse files Browse the repository at this point in the history
  • Loading branch information
Amila-Rukshan committed Sep 26, 2022
1 parent 4fe299c commit 6e33a8b
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ private ExtAuthMetrics() {
*
* @return ExtAuthMetrics
*/
public static synchronized ExtAuthMetrics getInstance() {
public static ExtAuthMetrics getInstance() {
if (extAuthMetricsMBean == null) {
Timer timer = new Timer();
extAuthMetricsMBean = new ExtAuthMetrics();
timer.schedule(extAuthMetricsMBean, 0, REQUEST_COUNT_INTERVAL_MILLIS);
synchronized (ExtAuthMetrics.class) {
if (extAuthMetricsMBean == null) {
Timer timer = new Timer();
extAuthMetricsMBean = new ExtAuthMetrics();
timer.schedule(extAuthMetricsMBean, 0, REQUEST_COUNT_INTERVAL_MILLIS);
}
}
}
return extAuthMetricsMBean;
}
Expand Down

0 comments on commit 6e33a8b

Please sign in to comment.