ThreadLocals and Thread Pools (#9592)
This commit is contained in:
parent
ded13f14b2
commit
94f50e785e
@ -0,0 +1,25 @@
|
|||||||
|
package com.baeldung.threadlocal;
|
||||||
|
|
||||||
|
import java.util.concurrent.BlockingQueue;
|
||||||
|
import java.util.concurrent.RejectedExecutionHandler;
|
||||||
|
import java.util.concurrent.ThreadFactory;
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
public class ThreadLocalAwareThreadPool extends ThreadPoolExecutor {
|
||||||
|
|
||||||
|
public ThreadLocalAwareThreadPool(int corePoolSize,
|
||||||
|
int maximumPoolSize,
|
||||||
|
long keepAliveTime,
|
||||||
|
TimeUnit unit,
|
||||||
|
BlockingQueue<Runnable> workQueue,
|
||||||
|
ThreadFactory threadFactory,
|
||||||
|
RejectedExecutionHandler handler) {
|
||||||
|
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory, handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void afterExecute(Runnable r, Throwable t) {
|
||||||
|
// Call remove on each ThreadLocal
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user