Monthly Archives: September 2015

Multithreading in Java using ThreadPoolExecutor

ThreadWorker is your custom class. 123456789try { ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(MAX_THREAD_SIZE); for (int i = 1; i Random randomGenerator = new Random(); executor.submit(new ThreadWorker("worker" + i, randomGenerator.nextInt(10))); LOG.info(i); } } catch (Exception e) { LOG.error("Hmm something is not right.", … Continue reading

Posted in Uncategorized | Leave a comment

Getting the caller method details using Java

12345678910 public static String getCallerClassName() {         StackTraceElement[] stElements = Thread.currentThread().getStackTrace();         for (int i=1; i<stElements.length; i++) {             StackTraceElement ste = stElements[i];             if … Continue reading

Posted in Uncategorized | Leave a comment