@Override protected void run() { while (isRunning()) { try { collectOperationalStats(); if (!isRunning()) { // Need to check here before sleep as the collectOperationStats may swallow interrupted exception break; } TimeUnit.SECONDS.sleep(statsRefreshInterval); } catch (InterruptedException e) { // Expected on stopping. So just break the loop break; } } }
@Override protected void run() { while (isRunning()) { try { collectOperationalStats(); if (!isRunning()) { // Need to check here before sleep as the collectOperationStats may swallow interrupted exception break; } TimeUnit.SECONDS.sleep(statsRefreshInterval); } catch (InterruptedException e) { // Expected on stopping. So just break the loop break; } } }