[vlma-devel] commit: Use AtomicBoolean here. (Adrien Grand )
git version control
git at videolan.org
Sun Aug 24 01:34:44 CEST 2008
vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Sun Aug 24 01:26:47 2008 +0200| [926576cbc86bd0dd1fb4fa5ae7a9dedb550640ea] | committer: Adrien Grand
Use AtomicBoolean here.
> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=926576cbc86bd0dd1fb4fa5ae7a9dedb550640ea
---
.../org/videolan/vlma/monitor/OrderMonitor.java | 9 +++++----
.../org/videolan/vlma/monitor/ServerMonitor.java | 10 ++++++----
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java b/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java
index 04eaa03..0bd52f0 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java
@@ -22,6 +22,7 @@ package org.videolan.vlma.monitor;
import java.util.List;
import java.util.Iterator;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.commons.configuration.Configuration;
import org.apache.log4j.Logger;
@@ -52,7 +53,7 @@ public class OrderMonitor implements Monitor {
private Thread orderMonitorDaemonThread;
- private boolean shouldRun;
+ private AtomicBoolean shouldRun = new AtomicBoolean(true);
private StreamWatcher streamWatcher;
@@ -144,8 +145,8 @@ public class OrderMonitor implements Monitor {
private Runnable orderMonitorDaemon = new Runnable() {
public void run() {
- shouldRun = true;
- while (shouldRun) {
+ shouldRun.set(true);
+ while (shouldRun.get()) {
// Wait before looping
try {
Thread.sleep(1000 * configuration.getInt("vlma.monitor.order.interval"));
@@ -168,7 +169,7 @@ public class OrderMonitor implements Monitor {
}
public synchronized void stop() {
- shouldRun = false;
+ shouldRun.set(false);
orderMonitorDaemonThread.interrupt();
}
diff --git a/vlma-core/src/main/java/org/videolan/vlma/monitor/ServerMonitor.java b/vlma-core/src/main/java/org/videolan/vlma/monitor/ServerMonitor.java
index b5775c1..2f8d0fa 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/monitor/ServerMonitor.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/monitor/ServerMonitor.java
@@ -20,6 +20,8 @@
package org.videolan.vlma.monitor;
+import java.util.concurrent.atomic.AtomicBoolean;
+
import org.apache.log4j.Logger;
import org.jrobin.core.Util;
import org.videolan.vlma.VLMaService;
@@ -46,7 +48,7 @@ public class ServerMonitor implements Monitor {
private Thread serverMonitorDaemonThread;
- private boolean shouldRun;
+ private AtomicBoolean shouldRun = new AtomicBoolean(false);
public boolean isUpdatingSNMPData() {
return (updateSNMPDataThread != null)
@@ -91,8 +93,8 @@ public class ServerMonitor implements Monitor {
*/
Runnable serverMonitorDaemon = new Runnable() {
public void run() {
- shouldRun = true;
- while (shouldRun) {
+ shouldRun.set(true);
+ while (shouldRun.get()) {
try {
// Wait before looping
Thread.sleep(1000 * (TIME_INTERVAL - (Util.getTime() % TIME_INTERVAL)));
@@ -115,7 +117,7 @@ public class ServerMonitor implements Monitor {
}
public synchronized void stop() {
- shouldRun = false;
+ shouldRun.set(false);
serverMonitorDaemonThread.interrupt();
}
More information about the vlma-devel
mailing list