Skip to content

Instantly share code, notes, and snippets.

View AlohaJava's full-sized avatar

Sergei Chamkin AlohaJava

View GitHub Profile
@mnadeem
mnadeem / ScalingThreadPoolExecutor.java
Last active October 27, 2021 21:36
Scalable Thread Pool Executor (TPE) Which first creates threads up to max pool size and then queue up the tasks (Queue Does not depends upon Executor)
import java.util.Collection;
import java.util.Iterator;
import java.util.concurrent.LinkedTransferQueue;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TransferQueue;
public final class ScalingThreadPoolExecutor extends ThreadPoolExecutor {