Code example for ScheduledThreadPoolExecutor

Methods: scheduleAtFixedRate

0
    final ServletContext context = contextEvent.getServletContext();
    final Injector injector = getInjector();
    final UserPing ping = injector.getInstance(UserPing.class);
    final ScheduledThreadPoolExecutor timer = injector
        .getInstance(ScheduledThreadPoolExecutor.class);
    timer.scheduleAtFixedRate(ping, PING_START_DELAY, PING_CHECK_DELAY, TimeUnit.MILLISECONDS);
    serverStarted = new Date();
    context.setAttribute(INJECTOR, injector);
    context.setAttribute(DATE_NAME, serverStarted);
 
    reconfigureLogging(contextEvent.getServletContext());
    reloadProperties(contextEvent.getServletContext());
  } 
 
  public static void reloadProperties(final ServletContext context) {
    final Injector injector = (Injector) context.getAttribute(INJECTOR);
    final Properties props = injector.getInstance(Properties.class);
    final File propsFile = new File(context.getRealPath("/WEB-INF/pyx.properties"));
    try { 
      props.clear();