コード例 #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
ファイル: BeanUtil.java プロジェクト: gmeurant/benerator
 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
ファイル: Distributor.java プロジェクト: superyfwy/db4o
 public void feed() {
   if (feeder == null) {
     return;
   }
   feeder.run();
 }