Skip to content

Commit c28bb67

Browse files
committed
Virtual PID thread should Die on disconnect
1 parent c5e589c commit c28bb67

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/main/java/com/neuronrobotics/sdk/pid/VirtualGenericPIDDevice.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ public class VirtualGenericPIDDevice extends GenericPIDDevice implements IHardwa
3232
private ArrayList<PDVelocityConfiguration> PDconfigs = new ArrayList<PDVelocityConfiguration>();
3333

3434
/** The sync. */
35-
SyncThread sync = new SyncThread();
35+
private SyncThread sync = new SyncThread();
36+
private boolean runSync =false;
3637

3738
/** The max ticks per second. */
3839
private double maxTicksPerSecond;
@@ -366,7 +367,7 @@ public void run() {
366367
PIDConfiguration[] toUpdate = new PIDConfiguration[numChannels] ;
367368
int updateIndex=0;
368369
long time;
369-
while (true) {
370+
while (runSync) {
370371
try {
371372
Thread.sleep(threadTime);
372373
} catch (InterruptedException ex) {
@@ -442,7 +443,7 @@ public boolean connect() {
442443
@Override
443444
public void disconnect() {
444445
fireDisconnectEvent();
445-
446+
runSync=false;
446447
}
447448

448449
}

0 commit comments

Comments
 (0)