All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.linmoure.thread.config.ThreadPoolConfig Maven / Gradle / Ivy

There is a newer version: 1.0.7
Show newest version
package io.github.linmoure.thread.config;

import lombok.Data;

import java.io.Serializable;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

@Data
public final class ThreadPoolConfig implements Serializable {
    public static final int REJECTED_POLICY_0 = 0;
    public static final int REJECTED_POLICY_1 = 1;
    public static final int REJECTED_POLICY_2 = 2;
    private String name;
    private int corePoolSize;
    private int maxPoolSize;
    private int queueCapacity;
    private int keepAliveSeconds;
    private int rejectedPolicy = 0;

    public BlockingQueue buildQueue() {
        BlockingQueue blockingQueue;
        if (this.queueCapacity <= 0) {
            blockingQueue = new LinkedBlockingQueue<>();
        } else {
            blockingQueue = new ArrayBlockingQueue<>(this.queueCapacity);
        }

        return blockingQueue;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy