Skip to content

Commit

Permalink
Minor hardening.
Browse files Browse the repository at this point in the history
  • Loading branch information
gsharma committed Oct 21, 2019
1 parent 24175ac commit 4cf8859
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/com/github/jaemons/ThreadProbe.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;

import org.apache.logging.log4j.LogManager;
Expand All @@ -23,10 +24,11 @@ public final class ThreadProbe extends Thread {
private final long probeMillis;
private final AtomicReference<ThreadsSnapshot> threadsSnapshot = new AtomicReference<>();
private final List<State> statesOfInterest = new ArrayList<>();
private final long probeMillisLowWatermark = TimeUnit.MILLISECONDS.toMillis(10L);

public ThreadProbe(final long probeMillis, final List<State> threadStatesOfInterest) {
this.probeMillis = probeMillis;
if (threadStatesOfInterest != null) {
this.probeMillis = Math.max(probeMillisLowWatermark, probeMillis);
if (threadStatesOfInterest != null && !threadStatesOfInterest.isEmpty()) {
statesOfInterest.addAll(threadStatesOfInterest);
} else {
statesOfInterest.addAll(Arrays.asList(State.values()));
Expand Down

0 comments on commit 4cf8859

Please sign in to comment.