Skip to content

Commit

Permalink
JENKINS-73431: moving to AtomicBoolean type
Browse files Browse the repository at this point in the history
  • Loading branch information
ironcerocloudbees committed Aug 19, 2024
1 parent 59a939f commit 7039d8a
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Logger;

/**
Expand All @@ -27,7 +28,7 @@ public class SlowRequestThreadDumpsGenerator extends Thread {
/**
* Semaphore to ensure that only one instance is collecting data at the same time.
*/
private static boolean running = false;
private static AtomicBoolean running = new AtomicBoolean(false);

/**
* How often (at minimum) we will capture the ThreadDump under a slowRequest scenario.
Expand Down Expand Up @@ -134,17 +135,11 @@ public static synchronized boolean checkThreadDumpsTrigger(long iota) {
}

private static boolean isRunning() {
boolean runningLocal;
synchronized (SlowRequestThreadDumpsGenerator.class) {
runningLocal = running;
}
return runningLocal;
return running.get();
}

private static void setRunningStatus(boolean runningLocal) {
synchronized (SlowRequestThreadDumpsGenerator.class) {
running = runningLocal;
}
running.set(runningLocal);
}

private static final Logger LOGGER = Logger.getLogger(SlowRequestThreadDumpsGenerator.class.getName());
Expand Down

0 comments on commit 7039d8a

Please sign in to comment.