Skip to content

Instantly share code, notes, and snippets.

@ilmoeuro
Created October 13, 2015 11:43
Show Gist options
  • Select an option

  • Save ilmoeuro/f5d892f1d21413cec1b2 to your computer and use it in GitHub Desktop.

Select an option

Save ilmoeuro/f5d892f1d21413cec1b2 to your computer and use it in GitHub Desktop.
process.java
public void init() throws InitializationException {
lockActuator.init();
modemController.init();
modemController.addPhoneCallListener((phoneNumber) -> {
eventQueue.offer(new PhoneCallEvent(phoneNumber));
});
}
@Override
@SuppressWarnings("SleepWhileInLoop")
public void run() {
thread.set(Thread.currentThread());
running.set(true);
log.info("Lock mechanism started");
while (running.get()) {
try {
PhoneCallEvent event = eventQueue.take();
if (memberLookup.isAuthorizedMember(event.getPhoneNumber())) {
lockActuator.setLockOpen(true);
Thread.sleep(lockOpenTime);
}
if (Thread.interrupted()) {
throw new InterruptedException();
}
} catch (InterruptedException ex) {
log.info("Lock mechanism interrupted");
} finally {
lockActuator.setLockOpen(false);
}
}
log.info("Lock mechanism stopped");
thread.set(null);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment