HashMap pour enum clés

J'avais posté un peu la même question avant aussi. J'ai obtenu des éclaircissements pour mes doutes. Mais toujours j'ai besoin de quelque chose de plus. La table de hachage sera initialisé avec l'enum objet à la clé et un pool de threads d'occurrence de la valeur. Je suis confus de comment initialiser la table de hachage pour chaque objet été appelé par certains autres processus ..Pour faire clair :
Mon programme, MyThreadpoolExcecutorPgm.java initialise une HashMap
Mon Progran AdditionHandler.java demande un filetage à partir de la table de hachage en passant ThreadpoolName (enum). Je suis "Sans fil disponibles à partir de HashMap" message. Svp aider moi.
Ci-dessous mon code:

 public class MyThreadpoolExcecutorPgm {

    enum ThreadpoolName {
        DR, BR, SV, MISCELLENEOUS;
    }

    private static String threadName;
    private static HashMap<ThreadpoolName, ThreadPoolExecutor>
        threadpoolExecutorHash;

    public MyThreadpoolExcecutorPgm(String p_threadName) {
        threadName = p_threadName;
    }

    public static void fillthreadpoolExecutorHash() {
        int poolsize = 3;
        int maxpoolsize = 3;
        long keepAliveTime = 10;
        ThreadPoolExecutor tp = null;
        threadpoolExecutorHash = new HashMap<ThreadpoolName, ThreadPoolExecutor>();
        for (ThreadpoolName poolName : ThreadpoolName.) //failing to implement
        {
            tp = new ThreadPoolExecutor(poolsize, maxpoolsize, keepAliveTime,
                    TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(5));
            threadpoolExecutorHash.put(poolName, tp);
        }
    }

    public static ThreadPoolExecutor getThreadpoolExcecutor(
            ThreadpoolName poolName) {
        ThreadPoolExecutor thread = null;
        if (threadpoolExecutorHash != null && poolName != null) {
            thread = threadpoolExecutorHash.get(poolName);
        } else {
            System.out.println("No thread available from HashMap");
        }
        return thread;
    }
}

AdditionHandler.java

public class AdditionHandler{

    public void handle() {
        AddProcess setObj = new AddProcess(5, 20);
        ThreadPoolExecutor tpe = null;
        ThreadpoolName poolName =ThreadpoolName.DR; //i am using my enum    
        tpe = MyThreadpoolExcecutorPgm.getThreadpoolExcecutor(poolName);
        tpe.execute(setObj);
    }

    public static void main(String[] args) {
        AdditionHandler obj = new AdditionHandler();
        obj.handle();
    }
}

OriginalL'auteur vidhya | 2011-02-09