public void run() { if (!_bStopHarvest) { boolean bLocalSleep = _bCurrentlySleepingBeforeExit; _bCurrentlySleepingBeforeExit = true; // (so won't sleep now when it gets to the end) _logger.error("Clean shutdown attempt"); _bStopHarvest = true; HarvestController.killHarvester(); if (bLocalSleep) { _mainThread.interrupt(); // (Don't mind the minor race condition that's here, worst case have to wait a few more // minutes) } // Wait at most 10 minutes for (int i = 0; i < 600; ++i) { try { if (_bReadyToTerminate) { break; } Thread.sleep(1000); } catch (InterruptedException e) { } } if (!_bReadyToTerminate) { _logger.error("Unclean shutdown #1"); } } }
@Override public void run() { _logger.info("Harvester reached max time, try to stop as quickly as possible"); _bStopHarvest = true; HarvestController.killHarvester(); }