List of usage examples for java.lang StringBuilder append
@Override public StringBuilder append(double d)
From source file:com.genentech.chemistry.openEye.apps.SDFTopologicalIndexer.java
/** * @param args/*from w w w . ja v a2 s. c o m*/ */ public static void main(String... args) throws IOException { // create command line Options object Options options = new Options(); Option opt = new Option(OPT_INFILE, true, "input file oe-supported Use .sdf|.smi to specify the file type."); opt.setRequired(true); opt.setArgName("fn"); options.addOption(opt); opt = new Option(OPT_OUTFILE, true, "output file oe-supported. Use .sdf|.smi to specify the file type."); opt.setRequired(true); opt.setArgName("fn"); options.addOption(opt); CommandLineParser parser = new PosixParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (Exception e) { System.err.println(e.getMessage()); exitWithHelp(options); } args = cmd.getArgs(); if (cmd.hasOption("d")) { System.err.println("Start debugger and press return:"); new BufferedReader(new InputStreamReader(System.in)).readLine(); } if (args.length == 0) { System.err.println("Specify at least one index type"); exitWithHelp(options); } String inFile = cmd.getOptionValue(OPT_INFILE); String outFile = cmd.getOptionValue(OPT_OUTFILE); Set<String> selectedIndexes = new HashSet<String>(args.length); if (args.length == 1 && "all".equalsIgnoreCase(args[0])) selectedIndexes = AVAILIndexes; else selectedIndexes.addAll(Arrays.asList(args)); if (!AVAILIndexes.containsAll(selectedIndexes)) { selectedIndexes.removeAll(AVAILIndexes); StringBuilder err = new StringBuilder("Unknown Index types: "); for (String it : selectedIndexes) err.append(it).append(" "); System.err.println(err); exitWithHelp(options); } SDFTopologicalIndexer sdfIndexer = new SDFTopologicalIndexer(outFile, selectedIndexes); sdfIndexer.run(inFile); sdfIndexer.close(); }
From source file:com.wyp.module.controller.LicenseController.java
public static void main(String[] args) { StringBuilder sb = new StringBuilder(); sb.append("1237275897295725"); String str = sb.toString();/*w w w . ja v a 2 s . co m*/ System.out.println(str); }
From source file:Main.java
public static void main(String[] args) throws IOException { String input = "this is a test"; StringBuilder result = new StringBuilder(); char currentCharacter; int count;//from w w w. j a v a 2 s . c o m for (int i = 0; i < input.length(); i++) { currentCharacter = input.charAt(i); count = 1; while (i < input.length() - 1 && input.charAt(i + 1) == currentCharacter) { count++; i++; } result.append(currentCharacter); result.append(count); } System.out.println("" + result); }
From source file:dhtaccess.benchmark.LatencyMeasure.java
public static void main(String[] args) { boolean details = false; int repeats = DEFAULT_REPEATS; boolean doPut = true; // parse options Options options = new Options(); options.addOption("h", "help", false, "print help"); options.addOption("d", "details", false, "requests secret hash and TTL"); options.addOption("r", "repeats", true, "number of requests"); options.addOption("n", "no-put", false, "does not put"); CommandLineParser parser = new PosixParser(); CommandLine cmd = null;//from ww w.jav a 2s.c om try { cmd = parser.parse(options, args); } catch (ParseException e) { System.out.println("There is an invalid option."); e.printStackTrace(); System.exit(1); } String optVal; if (cmd.hasOption('h')) { usage(COMMAND); System.exit(1); } if (cmd.hasOption('d')) { details = true; } optVal = cmd.getOptionValue('r'); if (optVal != null) { repeats = Integer.parseInt(optVal); } if (cmd.hasOption('n')) { doPut = false; } args = cmd.getArgs(); // parse arguments if (args.length < 1) { usage(COMMAND); System.exit(1); } // prepare for RPC int numAccessor = args.length; DHTAccessor[] accessorArray = new DHTAccessor[numAccessor]; try { for (int i = 0; i < numAccessor; i++) { accessorArray[i] = new DHTAccessor(args[i]); } } catch (MalformedURLException e) { e.printStackTrace(); System.exit(1); } // generate key prefix Random rnd = new Random(System.currentTimeMillis()); StringBuilder sb = new StringBuilder(); for (int i = 0; i < KEY_PREFIX_LENGTH; i++) { sb.append((char) ('a' + rnd.nextInt(26))); } String keyPrefix = sb.toString(); String valuePrefix = VALUE_PREFIX; // benchmarking System.out.println("Repeats " + repeats + " times."); if (doPut) { System.out.println("Putting: " + keyPrefix + "<number>"); for (int i = 0; i < repeats; i++) { byte[] key = null, value = null; try { key = (keyPrefix + i).getBytes(ENCODE); value = (valuePrefix + i).getBytes(ENCODE); } catch (UnsupportedEncodingException e) { e.printStackTrace(); System.exit(1); } int accIndex = rnd.nextInt(numAccessor); DHTAccessor acc = accessorArray[accIndex]; acc.put(key, value, TTL); } } System.out.println("Benchmarking by getting."); int count = 0; long startTime = System.currentTimeMillis(); if (details) { for (int i = 0; i < repeats; i++) { byte[] key = null; try { key = (keyPrefix + i).getBytes(ENCODE); } catch (UnsupportedEncodingException e) { e.printStackTrace(); System.exit(1); } int accIndex = rnd.nextInt(numAccessor); DHTAccessor acc = accessorArray[accIndex]; Set<DetailedGetResult> valueSet = acc.getDetails(key); if (valueSet != null && !valueSet.isEmpty()) { count++; } } } else { for (int i = 0; i < repeats; i++) { byte[] key = null; try { key = (keyPrefix + i).getBytes(ENCODE); } catch (UnsupportedEncodingException e) { e.printStackTrace(); System.exit(1); } int accIndex = rnd.nextInt(numAccessor); DHTAccessor acc = accessorArray[accIndex]; Set<byte[]> valueSet = acc.get(key); if (valueSet != null && !valueSet.isEmpty()) { count++; } } } System.out.println(System.currentTimeMillis() - startTime + " msec."); System.out.println("Rate of successful gets: " + count + " / " + repeats); }
From source file:com.heliosapm.opentsdb.client.boot.JavaAgentInstaller.java
public static void main(final String[] args) { if (args.length == 0) { loge("Usage: java com.heliosapm.opentsdb.client.boot.JavaAgentInstaller \n\t<PID | Name to match> \n\t[-list | -listjson] \n\t[-p k=v] \n\t[-config URL|File]"); }//from w ww .ja v a2 s . c om final long pid; if (isPid(args[0])) { pid = Long.parseLong(args[0].trim()); } else if ("-list".equalsIgnoreCase(args[0])) { printJVMs(myId); return; } else if ("-listjson".equalsIgnoreCase(args[0])) { printJVMsInJSON(myId); return; } else { pid = findPid(args[0]); } if (pid < 1) { System.exit(-1); } log("Installing JavaAgent to PID: %s from JAR: %s", pid, JavaAgentInstaller.class.getProtectionDomain().getCodeSource().getLocation()); VirtualMachine vm = null; try { final String loc = new File( JavaAgentInstaller.class.getProtectionDomain().getCodeSource().getLocation().getFile()) .getAbsolutePath(); vm = VirtualMachine.attach("" + pid); log("Connected to process %s, loading Agent from %s", vm.id(), loc); if (args.length > 1) { StringBuilder b = new StringBuilder(); for (int i = 1; i < args.length; i++) { b.append(args[i]).append("|~"); if ("-config".equalsIgnoreCase(args[i])) { i++; final URL url = URLHelper.toURL(args[i]); b.append(url).append("|~"); } } b.deleteCharAt(b.length() - 1); b.deleteCharAt(b.length() - 1); log("Loading with options [%s]", b); vm.loadAgent(loc, b.toString()); } else { log("Loading with no options"); vm.loadAgent(loc); } log("Agent loaded to process %s", vm.id()); System.exit((int) pid); } catch (Exception ex) { loge("Failed to attach to process %s. Stack trace follows...", pid); ex.printStackTrace(System.err); } finally { if (vm != null) { try { vm.detach(); log("Detached from process %s", pid); } catch (Exception ex) { } } } }
From source file:de.tudarmstadt.ukp.csniper.resbuild.EvaluationItemFixer.java
public static void main(String[] args) { connect(HOST, DATABASE, USER, PASSWORD); Map<Integer, String> items = new HashMap<Integer, String>(); Map<Integer, String> failed = new HashMap<Integer, String>(); // fetch coveredTexts of dubious items and clean it PreparedStatement select = null; try {//from w ww .j a v a 2 s .co m StringBuilder selectQuery = new StringBuilder(); selectQuery.append("SELECT * FROM EvaluationItem "); selectQuery.append("WHERE LOCATE(coveredText, ' ') > 0 "); selectQuery.append("OR LOCATE('" + LRB + "', coveredText) > 0 "); selectQuery.append("OR LOCATE('" + RRB + "', coveredText) > 0 "); selectQuery.append("OR LEFT(coveredText, 1) = ' ' "); selectQuery.append("OR RIGHT(coveredText, 1) = ' ' "); select = connection.prepareStatement(selectQuery.toString()); log.info("Running query [" + selectQuery.toString() + "]."); ResultSet rs = select.executeQuery(); while (rs.next()) { int id = rs.getInt("id"); String coveredText = rs.getString("coveredText"); try { // special handling of double whitespace: in this case, re-fetch the text if (coveredText.contains(" ")) { coveredText = retrieveCoveredText(rs.getString("collectionId"), rs.getString("documentId"), rs.getInt("beginOffset"), rs.getInt("endOffset")); } // replace bracket placeholders and trim the text coveredText = StringUtils.replace(coveredText, LRB, "("); coveredText = StringUtils.replace(coveredText, RRB, ")"); coveredText = coveredText.trim(); items.put(id, coveredText); } catch (IllegalArgumentException e) { failed.put(id, e.getMessage()); } } } catch (SQLException e) { log.error("Exception while selecting: " + e.getMessage()); } finally { closeQuietly(select); } // write logs BufferedWriter bwf = null; BufferedWriter bws = null; try { bwf = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(LOG_FAILED)), "UTF-8")); for (Entry<Integer, String> e : failed.entrySet()) { bwf.write(e.getKey() + " - " + e.getValue() + "\n"); } bws = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(new File(LOG_SUCCESSFUL)), "UTF-8")); for (Entry<Integer, String> e : items.entrySet()) { bws.write(e.getKey() + " - " + e.getValue() + "\n"); } } catch (IOException e) { log.error("Got an IOException while writing the log files."); } finally { IOUtils.closeQuietly(bwf); IOUtils.closeQuietly(bws); } log.info("Texts for [" + items.size() + "] items need to be cleaned up."); // update the dubious items with the cleaned coveredText PreparedStatement update = null; try { String updateQuery = "UPDATE EvaluationItem SET coveredText = ? WHERE id = ?"; update = connection.prepareStatement(updateQuery); int i = 0; for (Entry<Integer, String> e : items.entrySet()) { int id = e.getKey(); String coveredText = e.getValue(); // update item in database update.setString(1, coveredText); update.setInt(2, id); update.executeUpdate(); log.debug("Updating " + id + " with [" + coveredText + "]"); // show percentage of updated items i++; int part = (int) Math.ceil((double) items.size() / 100); if (i % part == 0) { log.info(i / part + "% finished (" + i + "/" + items.size() + ")."); } } } catch (SQLException e) { log.error("Exception while updating: " + e.getMessage()); } finally { closeQuietly(update); } closeQuietly(connection); }
From source file:com.asakusafw.generator.HadoopBulkLoaderDDLGenerator.java
/** * HadoopBulkLoader?????//www . j ava 2 s. c o m * * @param args * ?? * @throws Exception * ?????? */ public static void main(String[] args) throws Exception { String outputTablesString = findVariable(ENV_BULKLOADER_TABLES, true); List<String> outputTableList = null; if (outputTablesString != null && !OUTPUT_TABLES_PROPERTY.equals(outputTablesString)) { String[] outputTables = outputTablesString.trim().split("\\s+"); outputTableList = Arrays.asList(outputTables); } String ddlTemplate; InputStream in = HadoopBulkLoaderDDLGenerator.class.getResourceAsStream(TEMPLATE_DDL_FILENAME); try { ddlTemplate = IOUtils.toString(in); } finally { in.close(); } StringBuilder sb = new StringBuilder(); for (String tableName : args) { if (outputTableList == null || outputTableList.contains(tableName)) { String tableddl = ddlTemplate.replaceAll(TABLENAME_REPLACE_STRING, tableName); sb.append(tableddl); } } String outputFilePath = findVariable(ENV_BULKLOADER_GENDDL, true); if (outputFilePath == null) { throw new RuntimeException( "ASAKUSA_BULKLOADER_TABLES???????"); } FileUtils.write(new File(outputFilePath), sb); }
From source file:microbiosima.Microbiosima.java
/** * @param args//from w w w . j a v a 2 s. c o m * the command line arguments * @throws java.io.FileNotFoundException * @throws java.io.UnsupportedEncodingException */ public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException { //Init with default values int populationSize = 500; int microSize = 1000; int numberOfSpecies = 150; int numberOfGeneration = 10000; int numberOfObservation = 100; int numberOfReplication = 1; double pctEnv = 0; double pctPool = 0; Options options = new Options(); Option help = new Option("h", "help", false, "print this message"); Option version = new Option("v", "version", false, "print the version information and exit"); options.addOption(help); options.addOption(version); options.addOption(Option.builder("o").longOpt("obs").hasArg().argName("OBS") .desc("Number generation for observation [default: 100]").build()); options.addOption(Option.builder("r").longOpt("rep").hasArg().argName("REP") .desc("Number of replication [default: 1]").build()); Builder C = Option.builder("c").longOpt("config").numberOfArgs(4).argName("Pop Micro Spec Gen") .desc("Four Parameters in the following orders: " + "(1) population size, (2) microbe size, (3) number of species, (4) number of generation" + " [default: 500 1000 150 10000]"); options.addOption(C.build()); HelpFormatter formatter = new HelpFormatter(); String syntax = "microbiosima pctEnv pctPool"; String header = "\nSimulates the evolutionary and ecological dynamics of microbiomes within a population of hosts.\n\n" + "required arguments:\n" + " pctEnv Percentage of environmental acquisition\n" + " pctPool Percentage of pooled environmental component\n" + "\noptional arguments:\n"; String footer = "\n"; formatter.setWidth(80); CommandLineParser parser = new DefaultParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); String[] pct_config = cmd.getArgs(); if (cmd.hasOption("h") || args.length == 0) { formatter.printHelp(syntax, header, options, footer, true); System.exit(0); } if (cmd.hasOption("v")) { System.out.println("Microbiosima " + VERSION); System.exit(0); } if (pct_config.length != 2) { System.out.println("ERROR! Required exactly two argumennts for pct_env and pct_pool. It got " + pct_config.length + ": " + Arrays.toString(pct_config)); formatter.printHelp(syntax, header, options, footer, true); System.exit(3); } else { pctEnv = Double.parseDouble(pct_config[0]); pctPool = Double.parseDouble(pct_config[1]); if (pctEnv < 0 || pctEnv > 1) { System.out.println( "ERROR: pctEnv (Percentage of environmental acquisition) must be between 0 and 1 (pctEnv=" + pctEnv + ")! EXIT"); System.exit(3); } if (pctPool < 0 || pctPool > 1) { System.out.println( "ERROR: pctPool (Percentage of pooled environmental component must) must be between 0 and 1 (pctPool=" + pctPool + ")! EXIT"); System.exit(3); } } if (cmd.hasOption("config")) { String[] configs = cmd.getOptionValues("config"); populationSize = Integer.parseInt(configs[0]); microSize = Integer.parseInt(configs[1]); numberOfSpecies = Integer.parseInt(configs[2]); numberOfGeneration = Integer.parseInt(configs[3]); } if (cmd.hasOption("obs")) { numberOfObservation = Integer.parseInt(cmd.getOptionValue("obs")); } if (cmd.hasOption("rep")) { numberOfReplication = Integer.parseInt(cmd.getOptionValue("rep")); } } catch (ParseException e) { e.printStackTrace(); System.exit(3); } StringBuilder sb = new StringBuilder(); sb.append("Configuration Summary:").append("\n\tPopulation size: ").append(populationSize) .append("\n\tMicrobe size: ").append(microSize).append("\n\tNumber of species: ") .append(numberOfSpecies).append("\n\tNumber of generation: ").append(numberOfGeneration) .append("\n\tNumber generation for observation: ").append(numberOfObservation) .append("\n\tNumber of replication: ").append(numberOfReplication).append("\n"); System.out.println(sb.toString()); // System.exit(3); // LogNormalDistribution lgd=new LogNormalDistribution(0,1); // environment=lgd.sample(150); // double environment_sum=0; // for (int i=0;i<No;i++){ // environment_sum+=environment[i]; // } // for (int i=0;i<No;i++){ // environment[i]/=environment_sum; // } double[] environment = new double[numberOfSpecies]; for (int i = 0; i < numberOfSpecies; i++) { environment[i] = 1 / (double) numberOfSpecies; } for (int rep = 0; rep < numberOfReplication; rep++) { String prefix = "" + (rep + 1) + "_"; String sufix = "_E" + pctEnv + "_P" + pctPool + ".txt"; System.out.println("Output 5 result files in the format of: " + prefix + "[****]" + sufix); try { PrintWriter file1 = new PrintWriter( new BufferedWriter(new FileWriter(prefix + "gamma_diversity" + sufix))); PrintWriter file2 = new PrintWriter( new BufferedWriter(new FileWriter(prefix + "alpha_diversity" + sufix))); PrintWriter file3 = new PrintWriter( new BufferedWriter(new FileWriter(prefix + "beta_diversity" + sufix))); PrintWriter file4 = new PrintWriter(new BufferedWriter(new FileWriter(prefix + "sum" + sufix))); PrintWriter file5 = new PrintWriter( new BufferedWriter(new FileWriter(prefix + "inter_generation_distance" + sufix))); PrintWriter file6 = new PrintWriter( new BufferedWriter(new FileWriter(prefix + "environment_population_distance" + sufix))); Population population = new Population(microSize, environment, populationSize, pctEnv, pctPool, 0, 0); while (population.getNumberOfGeneration() < numberOfGeneration) { population.sumSpecies(); if (population.getNumberOfGeneration() % numberOfObservation == 0) { file1.println(population.gammaDiversity(true)); file2.println(population.alphaDiversity(true)); file3.print(population.betaDiversity(true)); file3.print("\t"); file3.println(population.BrayCurtis(true)); file4.println(population.printOut()); file5.println(population.interGenerationDistance()); file6.println(population.environmentPopulationDistance()); } population.getNextGen(); } file1.close(); file2.close(); file3.close(); file4.close(); file5.close(); file6.close(); } catch (IOException e) { e.printStackTrace(); } } }
From source file:com.linkedin.kmf.KafkaMonitor.java
public static void main(String[] args) throws Exception { if (args.length <= 0) { LOG.info("USAGE: java [options] " + KafkaMonitor.class.getName() + " config/kafka-monitor.properties"); return;/*from www . j av a 2 s .c o m*/ } StringBuilder buffer = new StringBuilder(); try (BufferedReader br = new BufferedReader(new FileReader(args[0].trim()))) { String line; while ((line = br.readLine()) != null) { if (!line.startsWith("#")) buffer.append(line); } } @SuppressWarnings("unchecked") Map<String, Map> props = new ObjectMapper().readValue(buffer.toString(), Map.class); KafkaMonitor kafkaMonitor = new KafkaMonitor(props); kafkaMonitor.start(); LOG.info("KafkaMonitor started"); kafkaMonitor.awaitShutdown(); }
From source file:com.amazonaws.services.kinesis.leases.impl.LeaseCoordinatorExerciser.java
public static void main(String[] args) throws InterruptedException, DependencyException, InvalidStateException, ProvisionedThroughputException, IOException { int numCoordinators = 9; int numLeases = 73; int leaseDurationMillis = 10000; int epsilonMillis = 100; AWSCredentialsProvider creds = new DefaultAWSCredentialsProviderChain(); AmazonDynamoDBClient ddb = new AmazonDynamoDBClient(creds); ILeaseManager<KinesisClientLease> leaseManager = new KinesisClientLeaseManager("nagl_ShardProgress", ddb); if (leaseManager.createLeaseTableIfNotExists(10L, 50L)) { LOG.info("Waiting for newly created lease table"); if (!leaseManager.waitUntilLeaseTableExists(10, 300)) { LOG.error("Table was not created in time"); return; }//from w w w. ja va 2s .co m } CWMetricsFactory metricsFactory = new CWMetricsFactory(creds, "testNamespace", 30 * 1000, 1000); final List<LeaseCoordinator<KinesisClientLease>> coordinators = new ArrayList<LeaseCoordinator<KinesisClientLease>>(); for (int i = 0; i < numCoordinators; i++) { String workerIdentifier = "worker-" + Integer.toString(i); LeaseCoordinator<KinesisClientLease> coord = new LeaseCoordinator<KinesisClientLease>(leaseManager, workerIdentifier, leaseDurationMillis, epsilonMillis, metricsFactory); coordinators.add(coord); } leaseManager.deleteAll(); for (int i = 0; i < numLeases; i++) { KinesisClientLease lease = new KinesisClientLease(); lease.setLeaseKey(Integer.toString(i)); lease.setCheckpoint(new ExtendedSequenceNumber("checkpoint")); leaseManager.createLeaseIfNotExists(lease); } final JFrame frame = new JFrame("Test Visualizer"); frame.setPreferredSize(new Dimension(800, 600)); final JPanel panel = new JPanel(new GridLayout(coordinators.size() + 1, 0)); final JLabel ticker = new JLabel("tick"); panel.add(ticker); frame.getContentPane().add(panel); final Map<String, JLabel> labels = new HashMap<String, JLabel>(); for (final LeaseCoordinator<KinesisClientLease> coord : coordinators) { JPanel coordPanel = new JPanel(); coordPanel.setLayout(new BoxLayout(coordPanel, BoxLayout.X_AXIS)); final Button button = new Button("Stop " + coord.getWorkerIdentifier()); button.setMaximumSize(new Dimension(200, 50)); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (coord.isRunning()) { coord.stop(); button.setLabel("Start " + coord.getWorkerIdentifier()); } else { try { coord.start(); } catch (LeasingException e) { LOG.error(e); } button.setLabel("Stop " + coord.getWorkerIdentifier()); } } }); coordPanel.add(button); JLabel label = new JLabel(); coordPanel.add(label); labels.put(coord.getWorkerIdentifier(), label); panel.add(coordPanel); } frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); new Thread() { // Key is lease key, value is green-ness as a value from 0 to 255. // Great variable name, huh? private Map<String, Integer> greenNesses = new HashMap<String, Integer>(); // Key is lease key, value is last owning worker private Map<String, String> lastOwners = new HashMap<String, String>(); @Override public void run() { while (true) { for (LeaseCoordinator<KinesisClientLease> coord : coordinators) { String workerIdentifier = coord.getWorkerIdentifier(); JLabel label = labels.get(workerIdentifier); List<KinesisClientLease> asgn = new ArrayList<KinesisClientLease>(coord.getAssignments()); Collections.sort(asgn, new Comparator<KinesisClientLease>() { @Override public int compare(KinesisClientLease arg0, KinesisClientLease arg1) { return arg0.getLeaseKey().compareTo(arg1.getLeaseKey()); } }); StringBuilder builder = new StringBuilder(); builder.append("<html>"); builder.append(workerIdentifier).append(":").append(asgn.size()).append(" "); for (KinesisClientLease lease : asgn) { String leaseKey = lease.getLeaseKey(); String lastOwner = lastOwners.get(leaseKey); // Color things green when they switch owners, decay the green-ness over time. Integer greenNess = greenNesses.get(leaseKey); if (greenNess == null || lastOwner == null || !lastOwner.equals(lease.getLeaseOwner())) { greenNess = 200; } else { greenNess = Math.max(0, greenNess - 20); } greenNesses.put(leaseKey, greenNess); lastOwners.put(leaseKey, lease.getLeaseOwner()); builder.append(String.format("<font color=\"%s\">%03d</font>", String.format("#00%02x00", greenNess), Integer.parseInt(leaseKey))).append(" "); } builder.append("</html>"); label.setText(builder.toString()); label.revalidate(); label.repaint(); } if (ticker.getText().equals("tick")) { ticker.setText("tock"); } else { ticker.setText("tick"); } try { Thread.sleep(200); } catch (InterruptedException e) { } } } }.start(); frame.pack(); frame.setVisible(true); for (LeaseCoordinator<KinesisClientLease> coord : coordinators) { coord.start(); } }