@Override public void run() { Instant now = Instant.now(); if (read.getLastAction() == null || read.getLastAction().plus(reconnectTime, ChronoUnit.SECONDS).isBefore(now)) { System.out.println("Reconnect due to lack of scan actions"); read.findAndConnectToTerminal(); read.setLastAction(now); } }