// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.server.worldgen.util;

import java.util.logging.Level;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.ThreadPoolExecutor;

public final class ChunkThreadPoolExecutor extends ThreadPoolExecutor
{
    private static final AtomicInteger GENERATION_COUNTER;
    private final int generation;
    private final Runnable shutdownHook;
    
    public ChunkThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit, final BlockingQueue<Runnable> workQueue, final ThreadFactory threadFactory, final Runnable shutdownHook) {
        super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory);
        this.generation = ChunkThreadPoolExecutor.GENERATION_COUNTER.getAndIncrement();
        this.shutdownHook = shutdownHook;
        LogUtil.getLogger().at(Level.INFO).log("Initialized ChunkGenerator-%d executor", this.generation);
    }
    
    @Override
    protected void terminated() {
        this.shutdownHook.run();
        LogUtil.getLogger().at(Level.INFO).log("ChunkGenerator-%d executor shutdown complete", this.generation);
    }
    
    static {
        GENERATION_COUNTER = new AtomicInteger(0);
    }
}
