thycotic-credentialstore-lib/src/main/java/com/streamsets/datacollector/credential/thycotic/api/AuthRenewalTask.java
public String getAccessToken() {
    if (System.currentTimeMillis() > getExpireTime()) {
      try {
        synchronized (this) {
          if (System.currentTimeMillis() > getExpireTime()) {
            accessToken = fetchAccessToken();
            if (accessToken != null && !accessToken.isEmpty()) {
              expires = (System.currentTimeMillis() + expires);
            }
          }
        }
      } catch (Exception e) {
        LOG.debug("Error in fetching the access token: {} ", e);
      }
    }
    return accessToken;
  }
public String getAccessToken() {
    if (System.currentTimeMillis() > getExpireTime()) {
      try {
        synchronized (this) {
          if (System.currentTimeMillis() > getExpireTime()) {
            accessToken = fetchAccessToken();
            if (accessToken != null && !accessToken.isEmpty()) {
              expires = (System.currentTimeMillis() + expires);
            }
          }
        }
      } catch (Exception e) {
        LOG.debug("Error in fetching the access token: {} ", e);
      }
    }
    return accessToken;
  }
<p>
Scheduler is not used since a dedicated thread will be running to update the token.Even if the
thycotic server is not being used,the thread will hit for every refresh interval to get a new
access token. So instead <tt>volatile</tt> variables are used to store the token.So only when
the token expires, thycotic server will be called to fetch the new token.
</p>
<p>
There are 2 expire checks to make sure that not more than one thread updates the token in case
of expiration