Skip to content

Commit 231792d

Browse files
committed
Thread safety
1 parent 1ffd6e1 commit 231792d

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/main/java/org/ros/internal/node/client/RemoteClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class RemoteClient implements Runnable {
3535
private Socket workerSocket = null; // socket assigned to slave port
3636
private SocketAddress workerSocketAddress; //address of slave
3737

38-
private boolean shouldRun = true; // master service thread control
38+
private volatile boolean shouldRun = true; // master service thread control
3939
private Object waitHalt = new Object();
4040

4141
ArrayBlockingQueue<RemoteRequestInterface> requests = new ArrayBlockingQueue<RemoteRequestInterface>(1);
@@ -70,7 +70,7 @@ public RemoteClient(String bootNode, int bootPort) throws IOException {
7070
@Override
7171
public void run() {
7272

73-
while(shouldRun ) {
73+
while(shouldRun) {
7474
try {
7575
// sets workerSocket
7676
send(requests.take());

src/main/java/org/ros/internal/node/server/TCPWorker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
public class TCPWorker implements Runnable {
2020
private static final boolean DEBUG = false;
2121
private static final Log log = LogFactory.getLog(TCPWorker.class);
22-
public boolean shouldRun = true;
22+
public volatile boolean shouldRun = true;
2323
private Socket dataSocket;
2424
private Object waitHalt = new Object();
2525
private RpcServer server; // the server we are servicing

src/main/java/org/ros/internal/transport/tcp/AsynchTCPWorker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
public class AsynchTCPWorker implements Runnable {
1717
private static final boolean DEBUG = false;
1818
private static final Log log = LogFactory.getLog(AsynchTCPWorker.class);
19-
public boolean shouldRun = true;
19+
public volatile boolean shouldRun = true;
2020
private ChannelHandlerContext ctx;
2121
private Object waitHalt = new Object();
2222

0 commit comments

Comments
 (0)