Java ThreadPoolExecutor getScheduler()

Here you can find the source of getScheduler()

Description

Returns scheduled thread-pool executor used for scheduling and execution of timer ticks.

License

Open Source License

Return

the common ScheduledThreadPoolExecutor object for scheduling timer ticks.

Declaration

static ScheduledThreadPoolExecutor getScheduler() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.concurrent.ScheduledThreadPoolExecutor;

public class Main {
    /**/*from   ww  w  .  jav  a2s.  com*/
     * Lock used to coordinate and synchronize all JPAZ related atomic actions
     */
    private static final Object jpazLock = new Object();
    /**
     * ScheduledThreadPoolExecutor used to schedule and execute timer ticks.
     */
    private static ScheduledThreadPoolExecutor tickExecutor = null;

    /**
     * Returns scheduled thread-pool executor used for scheduling and execution
     * of timer ticks.
     * 
     * @return the common ScheduledThreadPoolExecutor object for scheduling
     *         timer ticks.
     */
    static ScheduledThreadPoolExecutor getScheduler() {
        synchronized (getJPAZLock()) {
            if (tickExecutor == null) {
                tickExecutor = new ScheduledThreadPoolExecutor(1);
            }

            return tickExecutor;
        }
    }

    /**
     * Returns the object used as synchronization lock for all JPAZ objects. In
     * order to avoid deadlock and achieving mutual exclusion, all JPAZ objects
     * use the only shared lock. This object should be used as a lock for each
     * JPAZ atomic action.
     * 
     * @return synchronization the lock object.
     */
    public static synchronized Object getJPAZLock() {
        return jpazLock;
    }
}

Related

  1. createThreadPoolExecutor(final int queueSize, final String threadName)
  2. executeInBackground(Runnable r)
  3. executeInDaemon(Runnable... run)
  4. getBlockingWorkExecutor()
  5. getBoundedThreadPoolExecutor(int maxPoolSize, long keepAliveTime, TimeUnit unit, ThreadFactory tFactory)
  6. getThreadPoolExecutor(int poolSize, int[] poolInfo)
  7. getThreadPoolTrace(ThreadPoolExecutor threadpool)
  8. getWorkerCount(ThreadPoolExecutor workerExecutor)
  9. parseRejectionPolicy(String rejection_policy)