I am making a program in which I need to embed enum values ββin a HashMap. Can we do this? I tried it in many ways, but could not.
Can anybody help me? Through the program, I need to implement a HashMap containing 4 thread pools (whose names act as key) for which I have a ThreapoolExcecutor object.
Below is my code:
public class MyThreadpoolExcecutorPgm { enum ThreadpoolName { DR, PQ, EVENT, MISCELLENEOUS; } private static String threadName; private static HashMap<String, 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<String, ThreadPoolExecutor>(); ThreadpoolName poolName ; tp = new ThreadPoolExecutor(poolsize, maxpoolsize, keepAliveTime, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(5)); threadpoolExecutorHash.put(poolName,tp);
source share