List of usage examples for java.lang String String
public String(StringBuilder builder)
From source file:com.fengduo.bee.commons.core.lang.ArrayUtils.java
public static void main(String[] args) { String[] s = { "zxc", null, "msunmss", "" }; s = ArrayUtils.replaceNullElement(s, new IHandle<String>() { @Override// w w w. j a va 2 s.co m public boolean isNull(String obj) { return obj == null || StringUtils.isEmpty((String) obj); } @Override public String init(Class<String> clazz) { if (clazz.equals(String.class)) { return (String) new String("wu"); } try { return clazz.newInstance(); } catch (InstantiationException e) { System.out.println(e.getMessage()); } catch (IllegalAccessException e) { System.out.println(e.getMessage()); } System.out.println("replaceNullElement: init error"); return null; } }); System.out.println(StringUtils.join(s, ";")); String[] a = removeBlankElement(new String[] { "1", null, "2", "", "3" }); for (int i = 0, j = a.length; i < j; i++) { System.out.println(a[i]); } String[] t = null; System.out.println("Orignal:" + org.apache.commons.lang.ArrayUtils.toString(t, "NULL")); System.out.println("shift:" + org.apache.commons.lang.ArrayUtils.toString(shift(t, "a"), "NULL")); System.out.println("unshift:" + org.apache.commons.lang.ArrayUtils.toString(unshift(t, "a"), "NULL")); System.out.println("add(-1):" + org.apache.commons.lang.ArrayUtils.toString(add(t, -1, "a"), "NULL")); System.out.println("add(0):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 0, "a"), "NULL")); System.out.println("add(length):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 0, "a"), "NULL")); System.out.println("add(length+1):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 1, "a"), "NULL")); t = new String[] { "1", null, "2", "", "3" }; System.out.println("Orignal:" + org.apache.commons.lang.ArrayUtils.toString(t, "NULL")); System.out.println("shift:" + org.apache.commons.lang.ArrayUtils.toString(shift(t, "a"), "NULL")); System.out.println("unshift:" + org.apache.commons.lang.ArrayUtils.toString(unshift(t, "a"), "NULL")); System.out.println("add(-1):" + org.apache.commons.lang.ArrayUtils.toString(add(t, -1, "a"), "NULL")); System.out.println("add(0):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 0, "a"), "NULL")); System.out.println("add(length):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 0, "a"), "NULL")); System.out.println("add(length+1):" + org.apache.commons.lang.ArrayUtils.toString(add(t, 1, "a"), "NULL")); }
From source file:com.mozilla.socorro.RawDumpSizeScan.java
public static void main(String[] args) throws ParseException { String startDateStr = args[0]; String endDateStr = args[1];/*from w w w .j av a 2s .c om*/ // Set both start/end time and start/stop row Calendar startCal = Calendar.getInstance(); Calendar endCal = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); if (!StringUtils.isBlank(startDateStr)) { startCal.setTime(sdf.parse(startDateStr)); } if (!StringUtils.isBlank(endDateStr)) { endCal.setTime(sdf.parse(endDateStr)); } DescriptiveStatistics stats = new DescriptiveStatistics(); long numNullRawBytes = 0L; HTable table = null; Map<String, Integer> rowValueSizeMap = new HashMap<String, Integer>(); try { table = new HTable(TABLE_NAME_CRASH_REPORTS); Scan[] scans = generateScans(startCal, endCal); for (Scan s : scans) { ResultScanner rs = table.getScanner(s); Iterator<Result> iter = rs.iterator(); while (iter.hasNext()) { Result r = iter.next(); ImmutableBytesWritable rawBytes = r.getBytes(); //length = r.getValue(RAW_DATA_BYTES, DUMP_BYTES); if (rawBytes != null) { int length = rawBytes.getLength(); if (length > 20971520) { rowValueSizeMap.put(new String(r.getRow()), length); } stats.addValue(length); } else { numNullRawBytes++; } if (stats.getN() % 10000 == 0) { System.out.println("Processed " + stats.getN()); System.out.println(String.format("Min: %.02f Max: %.02f Mean: %.02f", stats.getMin(), stats.getMax(), stats.getMean())); System.out.println( String.format("1st Quartile: %.02f 2nd Quartile: %.02f 3rd Quartile: %.02f", stats.getPercentile(25.0d), stats.getPercentile(50.0d), stats.getPercentile(75.0d))); System.out.println("Number of large entries: " + rowValueSizeMap.size()); } } rs.close(); } System.out.println("Finished Processing!"); System.out.println(String.format("Min: %.02f Max: %.02f Mean: %.02f", stats.getMin(), stats.getMax(), stats.getMean())); System.out.println(String.format("1st Quartile: %.02f 2nd Quartile: %.02f 3rd Quartile: %.02f", stats.getPercentile(25.0d), stats.getPercentile(50.0d), stats.getPercentile(75.0d))); for (Map.Entry<String, Integer> entry : rowValueSizeMap.entrySet()) { System.out.println(String.format("RowId: %s => Length: %d", entry.getKey(), entry.getValue())); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (table != null) { try { table.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }
From source file:cloud.elasticity.elastman.App.java
/** * The entry point to the ElastMan main program. * /*from w w w. j a va 2s .co m*/ * @param args The first argument is the mode which can be inter, ident, or control * corresponding to interactive mode, system identification mode, or control mode. * The second argument is the configuration file * The third argument is password password */ public static void main(String[] args) { // 1) parse the command line // For more information http://commons.apache.org/cli/ Options options = new Options(); options.addOption("i", "ident", false, "Enter system identification mode."); options.addOption("c", "control", false, "Enter controller mode."); options.addOption("o", "options", true, "Configuration file. Default elastman.conf"); options.addOption("u", "username", true, "Username in the form Tenant:UserName"); options.addOption("p", "password", true, "User password"); options.addOption("k", "keyname", true, "Name of SSH key to use"); options.addOption("z", "zone", true, "The OpenStack availability zone such as the default RegionOne"); options.addOption("e", "endpoint", true, "The URL to access OpenStack API such as http://192.168.1.1:5000/v2.0/"); options.addOption("s", "syncserver", true, "The URL access the WebSyncServer"); options.addOption("h", "help", false, "Print this help"); CommandLineParser parser = new GnuParser(); try { cmd = parser.parse(options, args); } catch (ParseException e2) { System.out.println(e2.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("ElastMan", options, true); System.exit(1); } // if h then show help and exit if (cmd.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("ElastMan", options, true); System.exit(0); } // 2) Try to load the properties file. // Command line arguments override settings in the properties file // If no properties file exists. defaults will be used String filename = "control.prop"; // the default file name if (cmd.hasOption("o")) { filename = cmd.getOptionValue("o"); } Props.load(filename, cmd); // Props.save(filename); // System.exit(-1); // 3) If no password in command line nor in config file then ask the user if (Props.password == null) { Console cons; char[] passwd; if ((cons = System.console()) != null && // more secure and without echo! (passwd = cons.readPassword("[%s]", "Password:")) != null) { Props.password = new String(passwd); } else { // if you don't have a console! E.g., Running in eclipse System.out.print("Password: "); Props.password = scanner.nextLine(); } } // 4) Start the UI App app = new App(); app.textUI(args); }
From source file:cache.reverseproxy.CachedResponseParser.java
public static void main(String[] args) throws Exception { final HttpResponse httpresponse = getResponseFromParsedFile("address-validation-response.txt", false); System.out.println("PARSED RESPONSE ========>"); final StatusLine statusline = httpresponse.getStatusLine(); System.out.println(statusline.toString()); final Header[] headers = httpresponse.getAllHeaders(); for (Header header : headers) { System.out.println(header); }//from w w w . j a va 2 s. c o m HttpEntity entity = httpresponse.getEntity(); if (entity != null) { byte[] entityContent = EntityUtils.toByteArray(entity); System.out.println(new String(entityContent)); } }
From source file:com.zimbra.cs.util.SmtpInject.java
public static void main(String[] args) { CliUtil.toolSetup();// www.j av a2s . c om CommandLine cl = parseArgs(args); if (cl.hasOption("h")) { usage(null); } String file = null; if (!cl.hasOption("f")) { usage("no file specified"); } else { file = cl.getOptionValue("f"); } try { ByteUtil.getContent(new File(file)); } catch (IOException ioe) { usage(ioe.getMessage()); } String host = null; if (!cl.hasOption("a")) { usage("no smtp server specified"); } else { host = cl.getOptionValue("a"); } String sender = null; if (!cl.hasOption("s")) { usage("no sender specified"); } else { sender = cl.getOptionValue("s"); } String recipient = null; if (!cl.hasOption("r")) { usage("no recipient specified"); } else { recipient = cl.getOptionValue("r"); } boolean trace = false; if (cl.hasOption("T")) { trace = true; } boolean tls = false; if (cl.hasOption("t")) { tls = true; } boolean auth = false; String user = null; String password = null; if (cl.hasOption("A")) { auth = true; if (!cl.hasOption("u")) { usage("auth enabled, no user specified"); } else { user = cl.getOptionValue("u"); } if (!cl.hasOption("p")) { usage("auth enabled, no password specified"); } else { password = cl.getOptionValue("p"); } } if (cl.hasOption("v")) { mLog.info("SMTP server: " + host); mLog.info("Sender: " + sender); mLog.info("Recipient: " + recipient); mLog.info("File: " + file); mLog.info("TLS: " + tls); mLog.info("Auth: " + auth); if (auth) { mLog.info("User: " + user); char[] dummyPassword = new char[password.length()]; Arrays.fill(dummyPassword, '*'); mLog.info("Password: " + new String(dummyPassword)); } } Properties props = System.getProperties(); props.put("mail.smtp.host", host); if (auth) { props.put("mail.smtp.auth", "true"); } else { props.put("mail.smtp.auth", "false"); } if (tls) { props.put("mail.smtp.starttls.enable", "true"); } else { props.put("mail.smtp.starttls.enable", "false"); } // Disable certificate checking so we can test against // self-signed certificates props.put("mail.smtp.ssl.socketFactory", SocketFactories.dummySSLSocketFactory()); Session session = Session.getInstance(props, null); session.setDebug(trace); try { // create a message MimeMessage msg = new ZMimeMessage(session, new ZSharedFileInputStream(file)); InternetAddress[] address = { new JavaMailInternetAddress(recipient) }; msg.setFrom(new JavaMailInternetAddress(sender)); // attach the file to the message Transport transport = session.getTransport("smtp"); transport.connect(null, user, password); transport.sendMessage(msg, address); } catch (MessagingException mex) { mex.printStackTrace(); Exception ex = null; if ((ex = mex.getNextException()) != null) { ex.printStackTrace(); } System.exit(1); } }
From source file:Satellite.java
/** Program entry point. * @param args program arguments (unused here) */// w w w . ja v a 2 s . c o m public static void main(String[] args) { try { // configure Orekit AutoconfigurationCustom.configureOrekit(); // Initial state definition : date, orbit AbsoluteDate targetDate = new AbsoluteDate(2015, 12, 15, 2, 54, 27.000, TimeScalesFactory.getUTC()); //*******/ double mu = 3.986004415e+14; // gravitation coefficient //*******/ Frame inertialFrame = FramesFactory.getEME2000(); // inertial frame for orbit definition //*******/ Vector3D position = new Vector3D(-6142438.668, 3492467.560, -25767.25680); //*******/ Vector3D velocity = new Vector3D(505.8479685, 942.7809215, 7435.922231); //*******/ PVCoordinates pvCoordinates = new PVCoordinates(position, velocity); //*******/ Orbit initialOrbit = new KeplerianOrbit(pvCoordinates, inertialFrame, initialDate, mu); String Line1 = "1 25544U 98067A 15348.82280235 .00015563 00000-0 23610-3 0 9996"; String Line2 = "2 25544 51.6445 262.5935 0007865 276.8969 187.2494 15.54770155976144"; TLE TLEdata = new TLE(Line1, Line2); // Propagator : consider a simple keplerian motion (could be more elaborate) Propagator TLEProp = TLEPropagator.selectExtrapolator(TLEdata); // // Earth and frame // Frame earthFrame = FramesFactory.getITRF(IERSConventions.IERS_2010, true); // BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, // Constants.WGS84_EARTH_FLATTENING, // earthFrame); // // // Station // final double longitude = FastMath.toRadians(89.); // final double latitude = FastMath.toRadians(-8); // final double altitude = 0.; // final GeodeticPoint station1 = new GeodeticPoint(latitude, longitude, altitude); // final TopocentricFrame sta1Frame = new TopocentricFrame(earth, station1, "station1"); // // // Event definition // final double maxcheck = 60.0; // final double threshold = 0.001; // final double elevation = FastMath.toRadians(5.0); // final EventDetector sta1Visi = // new ElevationDetector(maxcheck, threshold, sta1Frame). // withConstantElevation(elevation). // withHandler(new VisibilityHandler()); // Add event to be detected //kepler.addEventDetector(sta1Visi); //Propagate from the initial date to the first raising or for the fixed duration //SpacecraftState finalState = kepler.propagate(initialDate.shiftedBy(1500.)); //System.out.println(" Final state : " + finalState.getDate().durationFrom(initialDate)); String stateVector = TLEProp.propagate(targetDate) .getPVCoordinates(FramesFactory.getITRF(IERSConventions.IERS_2010, true)).toString(); stateVector = stateVector.replace("{", "").replace("}", ""); //Removes brackets {} stateVector = stateVector.replace("(", "").replace(")", ""); //Removes parentheses () stateVector = stateVector.replace("P", "").replace("V", "").replace("A", ""); //Removes P, V, A stateVector = stateVector.replace(" ", ""); //Removes spaces String[] lineData = stateVector.split(","); String timeStamp = new String(lineData[0]); double[] position = new double[] { Double.parseDouble(lineData[1]), Double.parseDouble(lineData[2]), Double.parseDouble(lineData[3]) }; double[] velocity = new double[] { Double.parseDouble(lineData[4]), Double.parseDouble(lineData[5]), Double.parseDouble(lineData[6]) }; double[] acceleration = new double[] { Double.parseDouble(lineData[7]), Double.parseDouble(lineData[8]), Double.parseDouble(lineData[9]) }; position = Convert_To_Lat_Long(position); System.out.format("Latitude %.8f N%n", position[0]); System.out.format("Longitude %.8f E%n", position[1]); System.out.format("Altitude %.0f m %n", position[2]); } catch (OrekitException oe) { System.err.println(oe.getMessage()); } }
From source file:com.ibm.research.rdf.store.runtime.service.sql.UpdateHelper.java
public static void main(String[] args) { String JDBC_URL = "jdbc:db2://localhost:10997/lubm"; String user = "db2inst1"; String password = "db2admin"; String backend = "db2"; String schema = "db2inst1"; String store = "lubm_100m_r"; int lock = 1; int dph_size = 11; int rph_size = 4; String[][] triples = { { "http://usersub1/", "http://testpred1/", "http://userobj1/" }, { "http://usersub1/", "http://testpred2/", "http://userobj2/" }, { "http://usersub1/", "http://testpred1/", "userobj3" }, { "http://usersub2/", "http://testpred2/", "http://userobj2/" }, { "http://usersub1/", "http://testpred3/", "userobj4" }, { "http://usersub1/", "http://testpred4/", "userobj4" }, { "http://usersub2/", "http://testpred8/", "http://userobj2/" }, { "http://usersub2/", "http://testpred6/", "http://userobj2/" }, { "http://usersub2/", "http://testpred7/", "http://userobj2/" }, { "http://usersub1/", "http://testpred5/", "userobj5" }, { "http://usersub2/", "http://testpred9/", "http://userobj2/" }, { "http://usersub3/", "http://testpred2/", "http://userobj2/" }, { "http://usersub1/", "http://testpred1/", "userobj4" }, { "http://usersub1/", "http://testpred1/", "userobj5" }, { "http://usersub1/", "http://testpred3/", "userobj5" }, { "http://usersub4/", "http://testpred2/", "http://userobj2/" }, { "http://usersub3/", "http://testpred1/", "userobj3" } }; try {/* w w w .j av a 2s . c o m*/ String classNameString = new String("com.ibm.db2.jcc.DB2Driver"); Class.forName(classNameString); Connection conn = DriverManager.getConnection(JDBC_URL, user, password); String gid = "DEF"; //add triples to graph DEF for (int i = 0; i < triples.length; i++) { String sub = triples[i][0]; String pred = triples[i][1]; String obj = triples[i][2]; int obj_dt = obj.startsWith("http://") ? 10002 : 5001; int dft_col = i % 2; addTriple(conn, backend, schema, store, sub, pred, obj, obj_dt, dft_col, dft_col, gid, lock); } gid = "G1"; //add triples to graph G1 //some operations will fail due to UNIQUE indexes (on DS, RS) without GID for (int i = 0; i < triples.length; i++) { String sub = triples[i][0]; String pred = triples[i][1]; String obj = triples[i][2]; int obj_dt = obj.startsWith("http://") ? 10002 : 5001; int dft_col = i % 2; addTriple(conn, backend, schema, store, sub, pred, obj, obj_dt, dft_col, dft_col, gid, lock); } gid = "DEF"; //delete triples to graph DEF for (int i = triples.length - 1; i >= 0; i--) { String sub = triples[i][0]; String pred = triples[i][1]; String obj = triples[i][2]; int dft_col = i % 2; deleteTriple(conn, backend, schema, store, sub, pred, obj, dph_size, rph_size, dft_col, dft_col, gid, lock); } gid = "G1"; //delete triples to graph G1 for (int i = triples.length - 1; i >= 0; i--) { String sub = triples[i][0]; String pred = triples[i][1]; String obj = triples[i][2]; int dft_col = i % 2; deleteTriple(conn, backend, schema, store, sub, pred, obj, dph_size, rph_size, dft_col, dft_col, gid, lock); } } catch (SQLException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } }
From source file:Base64.java
/** Testing. */ public static void main(String[] args) { String s = "Hello, world"; s = "abcd";//from ww w. j av a 2s . c om //s = System.getProperties().toString(); //System.out.println( s + ": \n [" + encode( s ) + "]\n [" + decode(encode(s)) + "]" ); byte[] b = encodeString(s).getBytes(); byte[] c = decode(b, 0, b.length); System.out.println("\n\n" + s + ":" + new String(b) + ":" + new String(c)); try { FileInputStream fis = new FileInputStream("c:\\abcd.txt"); InputStream b64is = new InputStream(fis, DECODE); int ib = 0; while ((ib = b64is.read()) > 0) { //System.out.print( new String( ""+(char)ib ) ); } } // end try catch (Exception e) { e.printStackTrace(); } }
From source file:kellinwood.zipsigner.cmdline.Main.java
public static void main(String[] args) { try {/*from w w w .j a v a 2 s . c o m*/ Options options = new Options(); CommandLine cmdLine = null; Option helpOption = new Option("h", "help", false, "Display usage information"); Option modeOption = new Option("m", "keymode", false, "Keymode one of: auto, auto-testkey, auto-none, media, platform, shared, testkey, none"); modeOption.setArgs(1); Option keyOption = new Option("k", "key", false, "PCKS#8 encoded private key file"); keyOption.setArgs(1); Option pwOption = new Option("p", "keypass", false, "Private key password"); pwOption.setArgs(1); Option certOption = new Option("c", "cert", false, "X.509 public key certificate file"); certOption.setArgs(1); Option sbtOption = new Option("t", "template", false, "Signature block template file"); sbtOption.setArgs(1); Option keystoreOption = new Option("s", "keystore", false, "Keystore file"); keystoreOption.setArgs(1); Option aliasOption = new Option("a", "alias", false, "Alias for key/cert in the keystore"); aliasOption.setArgs(1); options.addOption(helpOption); options.addOption(modeOption); options.addOption(keyOption); options.addOption(certOption); options.addOption(sbtOption); options.addOption(pwOption); options.addOption(keystoreOption); options.addOption(aliasOption); Parser parser = new BasicParser(); try { cmdLine = parser.parse(options, args); } catch (MissingOptionException x) { System.out.println("One or more required options are missing: " + x.getMessage()); usage(options); } catch (ParseException x) { System.out.println(x.getClass().getName() + ": " + x.getMessage()); usage(options); } if (cmdLine.hasOption(helpOption.getOpt())) usage(options); Properties log4jProperties = new Properties(); log4jProperties.load(new FileReader("log4j.properties")); PropertyConfigurator.configure(log4jProperties); LoggerManager.setLoggerFactory(new Log4jLoggerFactory()); List<String> argList = cmdLine.getArgList(); if (argList.size() != 2) usage(options); ZipSigner signer = new ZipSigner(); signer.addAutoKeyObserver(new Observer() { @Override public void update(Observable observable, Object o) { System.out.println("Signing with key: " + o); } }); Class bcProviderClass = Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider"); Provider bcProvider = (Provider) bcProviderClass.newInstance(); KeyStoreFileManager.setProvider(bcProvider); signer.loadProvider("org.spongycastle.jce.provider.BouncyCastleProvider"); PrivateKey privateKey = null; if (cmdLine.hasOption(keyOption.getOpt())) { if (!cmdLine.hasOption(certOption.getOpt())) { System.out.println("Certificate file is required when specifying a private key"); usage(options); } String keypw = null; if (cmdLine.hasOption(pwOption.getOpt())) keypw = pwOption.getValue(); else { keypw = new String(readPassword("Key password")); if (keypw.equals("")) keypw = null; } URL privateKeyUrl = new File(keyOption.getValue()).toURI().toURL(); privateKey = signer.readPrivateKey(privateKeyUrl, keypw); } X509Certificate cert = null; if (cmdLine.hasOption(certOption.getOpt())) { if (!cmdLine.hasOption(keyOption.getOpt())) { System.out.println("Private key file is required when specifying a certificate"); usage(options); } URL certUrl = new File(certOption.getValue()).toURI().toURL(); cert = signer.readPublicKey(certUrl); } byte[] sigBlockTemplate = null; if (cmdLine.hasOption(sbtOption.getOpt())) { URL sbtUrl = new File(sbtOption.getValue()).toURI().toURL(); sigBlockTemplate = signer.readContentAsBytes(sbtUrl); } if (cmdLine.hasOption(keyOption.getOpt())) { signer.setKeys("custom", cert, privateKey, sigBlockTemplate); signer.signZip(argList.get(0), argList.get(1)); } else if (cmdLine.hasOption(modeOption.getOpt())) { signer.setKeymode(modeOption.getValue()); signer.signZip(argList.get(0), argList.get(1)); } else if (cmdLine.hasOption((keystoreOption.getOpt()))) { String alias = null; if (!cmdLine.hasOption(aliasOption.getOpt())) { KeyStore keyStore = KeyStoreFileManager.loadKeyStore(keystoreOption.getValue(), (char[]) null); for (Enumeration<String> e = keyStore.aliases(); e.hasMoreElements();) { alias = e.nextElement(); System.out.println("Signing with key: " + alias); break; } } else alias = aliasOption.getValue(); String keypw = null; if (cmdLine.hasOption(pwOption.getOpt())) keypw = pwOption.getValue(); else { keypw = new String(readPassword("Key password")); if (keypw.equals("")) keypw = null; } CustomKeySigner.signZip(signer, keystoreOption.getValue(), null, alias, keypw.toCharArray(), "SHA1withRSA", argList.get(0), argList.get(1)); } else { signer.setKeymode("auto-testkey"); signer.signZip(argList.get(0), argList.get(1)); } } catch (Throwable t) { t.printStackTrace(); } }
From source file:com.inclouds.hbase.utils.RegionServerPoker.java
public static void main(String[] args) throws IOException { parseArgs(args);/*from w w w. ja va 2 s. c om*/ byte[] name = "usertable".getBytes(); Configuration cfg = HBaseConfiguration.create(); HTable table = new HTable(cfg, name); List<byte[]> keys = selectRandomKeys(table); LOG.info("Found keys:\n"); for (byte[] k : keys) { LOG.info(new String(k)); } Poker[] workers = new Poker[threads]; for (int i = 0; i < threads; i++) { workers[i] = (reuseConfig == false) ? new Poker(i, keys) : new Poker(i, cfg, keys); workers[i].start(); } // Start stats timer = new Timer(); timer.schedule(new Stats(), 5000, 5000); // Join all workers for (int i = 0; i < threads; i++) { try { workers[i].join(); } catch (InterruptedException e) { // TODO Auto-generated catch block //e.printStackTrace(); } } LOG.info("Finished: " + ((double) completed.get() * 1000) / (endTime.get() - startTime.get()) + " RPS"); System.exit(-1); }