Ejemplo n.º 1
0
 /**
  * Remove the specified eviction task from the timer.
  * @param task      Task to be scheduled
  */
 static internal void cancel(java.util.TimerTask task)
 {
     lock (lockJ)
         task.cancel();
     _usageCount--;
     if (_usageCount == 0)
     {
         _timer.cancel();
         _timer = null;
     }
 }
Ejemplo n.º 2
0
 /**
  * Add the specified eviction task to the timer. Tasks that are added with a
  * call to this method *must* call {@link #cancel(TimerTask)} to cancel the
  * task to prevent memory and/or thread leaks in application server
  * environments.
  * @param task      Task to be scheduled
  * @param delay     Delay in milliseconds before task is executed
  * @param period    Time in milliseconds between executions
  */
 static internal void schedule(java.util.TimerTask task, long delay, long period)
 {
     lock (lockJ)
     {
         if (null == _timer)
         {
             // Force the new Timer thread to be created with a context class
             // loader set to the class loader that loaded this library
             java.lang.ClassLoader ccl = new PrivilegedGetTccl().run();
             try
             {
                 new PrivilegedSetTccl(typeof(EvictionTimer).getClass().getClassLoader());
                 _timer = new java.util.Timer(true);
             }
             finally
             {
                 new PrivilegedSetTccl(ccl);
             }
         }
         _usageCount++;
         _timer.schedule(task, delay, period);
     }
 }