/**
  * 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;
 }
Beispiel #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);
   }
 }
Beispiel #3
0
 public void feed() {
   if (feeder == null) {
     return;
   }
   feeder.run();
 }