Skip to content

Commit

Permalink
Change delay mechanism in WebcamDiscoveryService
Browse files Browse the repository at this point in the history
  • Loading branch information
sarxos committed Feb 20, 2013
1 parent 0ce18b5 commit 5111d85
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,20 @@ public void run() {
// wait initial time interval since devices has been initially
// discovered

Object monitor = new Object();

do {

delay();
synchronized (monitor) {
try {
monitor.wait(support.getScanInterval());
} catch (InterruptedException e) {
if (LOG.isTraceEnabled()) {
LOG.error("Interrupted", e);
}
break;
}
}

WebcamDiscoveryListener[] listeners = Webcam.getDiscoveryListeners();

Expand Down Expand Up @@ -267,14 +278,6 @@ private static void notifyWebcamFound(Webcam webcam, WebcamDiscoveryListener[] l
}
}

private void delay() {
try {
Thread.sleep(support.getScanInterval());
} catch (InterruptedException e) {
throw new WebcamException(e);
}
}

/**
* Stop discovery service.
*/
Expand Down

0 comments on commit 5111d85

Please sign in to comment.