...
Code Block | ||
---|---|---|
| ||
class CustomThreadPoolExecutor extends ThreadPoolExecutor { public CustomThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) { super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue); } @Override public void beforeExecute(Thread t, Runnable r) { if (t == null || r == null) { throw new NullPointerException(); } Diary.setDay(Day.MONDAY); super.beforeExecute(t, r); } } public final class DiaryPool { // ... DiaryPool() { exec = new CustomThreadPoolExecutor(NumOfthreads, NumOfthreads, 10, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10)); diary = new Diary(); } // ... } |
Exceptions
TPS04-J-EX0: It is unnecessary to reinitialize a ThreadLocal
object that does not change state after initialization. For example, there may be only one type of database connection represented by the initial value of the ThreadLocal
object.
...