Source:
<code>protected boolean checkTenantAutoUnloading(String tenantDomain) throws LazyLoadingTestException { boolean isTenantUnloaded = false; log.info("Sleeping for " + TENANT_IDLE_TIME + " milliseconds (Tenant idle tome)."); try { Thread.sleep(TENANT_IDLE_TIME); } catch (InterruptedException interruptedException) { String customErrorMessage = "InterruptedException occurs when sleeping for TENANT_IDLE_TIME" + interruptedException.getMessage(); log.error(customErrorMessage); throw new LazyLoadingTestException(customErrorMessage, interruptedException); } long totalSleepTime = 0; long startTime = System.currentTimeMillis(); while (System.currentTimeMillis() - startTime < MAX_THRESHOLD_TIME) { isTenantUnloaded = !getTenantStatus(tenantDomain).isTenantContextLoaded(); totalSleepTime = System.currentTimeMillis() - startTime + TENANT_IDLE_TIME; if (isTenantUnloaded) { log.info("Tenant " + tenantDomain + " is unloaded in " + totalSleepTime + "milliseconds. Tenant idle " + "time is :" + TENANT_IDLE_TIME + "milliseconds."); break; } else { try { <START> Thread.sleep(1000); <END> } catch (InterruptedException interruptedException) { String customErrorMessage = "InterruptedException occurs when sleeping 1000 milliseconds and while" + " waiting for tenant to auto unload" + interruptedException.getMessage(); log.error(customErrorMessage); throw new LazyLoadingTestException(customErrorMessage, interruptedException); } } } if (!isTenantUnloaded) { log.info("Tenant " + tenantDomain + " is not unloaded in " + totalSleepTime + "milliseconds. Tenant idle " + "time is :" + TENANT_IDLE_TIME + "milliseconds."); } return isTenantUnloaded; }</code><technical_language>explain need thread sleep ? reduce wait time 500 ms</technical_language>

Target:
protected boolean checkTenantAutoUnloading(String tenantDomain) throws LazyLoadingTestException { boolean isTenantUnloaded = false; long totalSleepTime = 0; log.info("Sleeping for " + tenantIdleTime + " milliseconds (Tenant idle time)."); try { Thread.sleep(tenantIdleTime); } catch (InterruptedException interruptedException) { String customErrorMessage = "InterruptedException occurs when sleeping for tenantIdleTime" + interruptedException.getMessage(); log.warn(customErrorMessage, interruptedException); } long startTime = System.currentTimeMillis(); while (System.currentTimeMillis() - startTime < MAX_THRESHOLD_TIME) { isTenantUnloaded = !getTenantStatus(tenantDomain).isTenantContextLoaded(); totalSleepTime = System.currentTimeMillis() - startTime + tenantIdleTime; if (isTenantUnloaded) { log.info("Tenant " + tenantDomain + " is unloaded in " + totalSleepTime + "milliseconds. Tenant idle " + "time is :" + tenantIdleTime + "milliseconds."); break; } else { try { Thread.sleep(1000); } catch (InterruptedException interruptedException) { String customErrorMessage = "InterruptedException occurs when sleeping 1000 milliseconds and while waiting for tenant" + " to auto unload" + interruptedException.getMessage(); log.warn(customErrorMessage, interruptedException); } } } if (!isTenantUnloaded) { log.info("Tenant " + tenantDomain + " is not unloaded in " + totalSleepTime + "milliseconds. Tenant idle " + "time is :" + tenantIdleTime + "milliseconds."); } return isTenantUnloaded; }