Java ThreadPoolExecutor parseRejectionPolicy(String rejection_policy)

Here you can find the source of parseRejectionPolicy(String rejection_policy)

Description

parse Rejection Policy

License

LGPL

Declaration

public static RejectedExecutionHandler parseRejectionPolicy(String rejection_policy) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.util.concurrent.*;

public class Main {
    public static RejectedExecutionHandler parseRejectionPolicy(String rejection_policy) {
        if (rejection_policy == null)
            throw new IllegalArgumentException("rejection policy is null");
        if (rejection_policy.equalsIgnoreCase("abort"))
            return new ThreadPoolExecutor.AbortPolicy();
        if (rejection_policy.equalsIgnoreCase("discard"))
            return new ThreadPoolExecutor.DiscardPolicy();
        if (rejection_policy.equalsIgnoreCase("discardoldest"))
            return new ThreadPoolExecutor.DiscardOldestPolicy();
        if (rejection_policy.equalsIgnoreCase("run"))
            return new ThreadPoolExecutor.CallerRunsPolicy();
        throw new IllegalArgumentException("rejection policy \"" + rejection_policy + "\" not known");
    }//from  w  w  w .j  av a  2  s . co m
}

Related

  1. getBoundedThreadPoolExecutor(int maxPoolSize, long keepAliveTime, TimeUnit unit, ThreadFactory tFactory)
  2. getScheduler()
  3. getThreadPoolExecutor(int poolSize, int[] poolInfo)
  4. getThreadPoolTrace(ThreadPoolExecutor threadpool)
  5. getWorkerCount(ThreadPoolExecutor workerExecutor)