1 16 17 package org.apache.log4j.varia.test; 18 19 import org.apache.log4j.Logger; 20 import org.apache.log4j.PropertyConfigurator; 21 22 28 public class Loop { 29 30 static Logger cat = Logger.getLogger(Loop.class); 31 static int loopLength; 32 33 public 34 static 35 void main(String argv[]) { 36 37 if(argv.length == 2) 38 init(argv[0], argv[1]); 39 else 40 usage("Wrong number of arguments."); 41 test(); 42 } 43 44 45 static 46 void usage(String msg) { 47 System.err.println(msg); 48 System.err.println( "Usage: java " + Loop.class.getName() + 49 "configFile loopLength"); 50 System.exit(1); 51 } 52 53 54 static 55 void init(String configFile, String loopStr) { 56 PropertyConfigurator.configure(configFile); 57 try { 58 loopLength = Integer.parseInt(loopStr); 59 } 60 catch(java.lang.NumberFormatException e) { 61 e.printStackTrace(); 62 usage("Could not interpret loopLength ["+ loopStr +"]."); 63 } 64 } 65 66 static 67 void test() { 68 for(int i=0; i < loopLength; i++) { 69 Thread.yield(); 70 cat.debug("MSG "+i); 71 } 72 } 73 } 74 | Popular Tags |