예제 #1
0
 /**
  * This method runs the Runnable and measures how long it takes.
  *
  * @param r is the Runnable for the task that we want to measure
  * @return the time it took to execute this task
  */
 public static long time(Runnable r) {
   long time = -System.currentTimeMillis();
   r.run();
   time += System.currentTimeMillis();
   System.out.println("Took " + time + "ms");
   return time;
 }
예제 #2
0
 public static void runWithJarClassLoader(File jarFile, Runnable action)
     throws MalformedURLException {
   Thread currentThread = Thread.currentThread();
   ClassLoader contextClassLoader = currentThread.getContextClassLoader();
   try {
     currentThread.setContextClassLoader(createJarClassLoader(jarFile));
     action.run();
   } finally {
     currentThread.setContextClassLoader(contextClassLoader);
   }
 }
예제 #3
0
 public void feed() {
   if (feeder == null) {
     return;
   }
   feeder.run();
 }