|
@@ -78,12 +78,16 @@ public class JvmPauseMonitor {
|
|
|
Preconditions.checkState(monitorThread == null,
|
|
|
"Already started");
|
|
|
monitorThread = new Daemon(new Monitor());
|
|
|
- monitorThread.start();
|
|
|
+ if (shouldRun) {
|
|
|
+ monitorThread.start();
|
|
|
+ } else {
|
|
|
+ LOG.warn("stop() was called before start() completed");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void stop() {
|
|
|
shouldRun = false;
|
|
|
- if (monitorThread != null) {
|
|
|
+ if (isStarted()) {
|
|
|
monitorThread.interrupt();
|
|
|
try {
|
|
|
monitorThread.join();
|