public class Test1 { public static void main(String[] args) throws Exception { int numReqs = Integer.parseInt(args[0]); int maxLive = Integer.parseInt(args[1]); int timeOut = Integer.parseInt(args[2]); System.out.println("=== Test numReqs " + numReqs + " maxLive " + maxLive + " timeOut " + timeOut); String[] names = new String[]{"ak149","bmc26","bws5","cph4","dmt17","dsh8","ejd9","hjg10","jdb29","jlm47","jps22","jr94","kgas1","kjjg1","lb65","mdb29","mfb3","mfma2","mjh77","mm236","mrl13","mrr21","msb26","njh34","no15","ns127","rdc12","rgf5","rgs10","rlb22","rsb16","sb144","sdw14","sjv14","sk218","src17","swp4","tc99","tcg4"}; for (String alloc: names) { System.out.println( "=== allocStart " + alloc); for (String tester: names) { runWithTimeOut( alloc, tester, numReqs, maxLive, timeOut); } System.out.println( "=== allocDone " + alloc); } System.exit(0); } public static void runWithTimeOut( final String allocater, final String tester, final int numReqs, final int maxLive, int timeOut) throws Exception { System.out.println( "=== start " + allocater + " " + tester); Thread thread = new Thread(new Runnable() { public void run() { try { Alloc a = (Alloc) Class.forName("Alloc_"+allocater).newInstance(); a.init( (int) Math.ceil(maxLive *1.5)); AllocTest at = (AllocTest) Class.forName("AllocTest_"+tester).newInstance(); long startTimeMillis = System.currentTimeMillis(); int failed = at.run( a, numReqs, maxLive, 0); long duration = System.currentTimeMillis() - startTimeMillis; System.out.println( "=== ok " + allocater + " " + tester + " " + failed + " " + a.currentlyAllocated() + " " + duration); } catch (Exception e) { System.out.println( "=== failed " + allocater + " " + tester + " " + e.getMessage()); } } }); thread.start(); long endTimeMillis = System.currentTimeMillis() + timeOut; while (thread.isAlive()) { if (System.currentTimeMillis() > endTimeMillis) { // set an error flag thread.stop(); System.out.println( "=== timeOut " + allocater + " " + tester + " " + (System.currentTimeMillis() - endTimeMillis)); break; } try { Thread.sleep(500); } catch (InterruptedException t) { System.out.println( "=== interrupt " + allocater + " " + tester + " " + t.getMessage()); } } } }