Example usage for java.lang Thread sleep

List of usage examples for java.lang Thread sleep

Introduction

In this page you can find the example usage for java.lang Thread sleep.

Prototype

public static native void sleep(long millis) throws InterruptedException;

Source Link

Document

Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds, subject to the precision and accuracy of system timers and schedulers.

Usage

From source file:com.benchmark.TikaCLI.java

public static void main(String[] args) throws Exception {
    //        BasicConfigurator.configure(
    //                new WriterAppender(new SimpleLayout(), System.err));
    //        Logger.getRootLogger().setLevel(Level.INFO);

    TikaCLI cli = new TikaCLI();
    if (args.length > 0) {
        for (int i = 0; i < args.length; i++) {
            cli.process(args[i]);/*from www .j av  a 2 s .  co m*/
        }
        if (cli.pipeMode) {
            cli.process("-");
        }
    } else {
        // Started with no arguments. Wait for up to 0.1s to see if
        // we have something waiting in standard input and use the
        // pipe mode if we have. If no input is seen, start the GUI.
        if (System.in.available() == 0) {
            Thread.sleep(100);
        }
        if (System.in.available() > 0) {
            cli.process("-");
        } else {
            cli.process("--gui");
        }
    }
}

From source file:ProdCons2.java

public static void main(String[] args) throws IOException, InterruptedException {

    // Start producers and consumers
    int numProducers = 4;
    int numConsumers = 3;
    ProdCons2 pc = new ProdCons2(numProducers, numConsumers);

    // Let it run for, say, 10 seconds
    Thread.sleep(10 * 1000);

    // End of simulation - shut down gracefully
    synchronized (pc.list) {
        pc.done = true;/*from   www.  j av a2s.c  om*/
        pc.list.notifyAll();
    }
}

From source file:org.wso2.carbon.sample.atmstats.ATMTransactionStatsClient.java

public static void main(String[] args) throws XMLStreamException {
    System.out.println(xmlMsgs.get(1));
    System.out.println(xmlMsgs.get(2));
    System.out.println(xmlMsgs.get(3));
    KeyStoreUtil.setTrustStoreParams();//from   w  ww .ja v  a2 s.  co  m
    String url = args[0];
    String username = args[1];
    String password = args[2];

    HttpClient httpClient = new SystemDefaultHttpClient();

    try {
        HttpPost method = new HttpPost(url);

        for (String xmlElement : xmlMsgs) {
            StringEntity entity = new StringEntity(xmlElement);
            method.setEntity(entity);
            if (url.startsWith("https")) {
                processAuthentication(method, username, password);
            }
            httpClient.execute(method).getEntity().getContent().close();
        }
        Thread.sleep(500); // We need to wait some time for the message to be sent

    } catch (Throwable t) {
        t.printStackTrace();
    }
}

From source file:fi.helsinki.cs.iot.kahvihub.KahviHub.java

public static void main(String[] args) throws InterruptedException {
    // create Options object
    Options options = new Options();
    // add conf file option
    options.addOption("c", true, "config file");
    CommandLineParser parser = new BasicParser();
    CommandLine cmd;//from  w w  w  .  ja  v a 2  s .  c o  m
    try {
        cmd = parser.parse(options, args);
        String configFile = cmd.getOptionValue("c");
        if (configFile == null) {
            Log.e(TAG, "The config file option was not provided");
            // automatically generate the help statement
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("d", options);
            System.exit(-1);
        } else {
            try {
                HubConfig hubConfig = ConfigurationFileParser.parseConfigurationFile(configFile);
                Path libdir = Paths.get(hubConfig.getLibdir());
                if (hubConfig.isDebugMode()) {
                    File dir = libdir.toFile();
                    if (dir.exists() && dir.isDirectory())
                        for (File file : dir.listFiles())
                            file.delete();
                }
                final IotHubHTTPD server = new IotHubHTTPD(hubConfig.getPort(), libdir, hubConfig.getHost());
                init(hubConfig);
                try {
                    server.start();
                } catch (IOException ioe) {
                    Log.e(TAG, "Couldn't start server:\n" + ioe);
                    System.exit(-1);
                }
                Runtime.getRuntime().addShutdownHook(new Thread() {
                    @Override
                    public void run() {
                        server.stop();
                        Log.i(TAG, "Server stopped");
                    }
                });

                while (true) {
                    Thread.sleep(1000);
                }
            } catch (ConfigurationParsingException | IOException e) {
                System.out.println("1:" + e.getMessage());
                Log.e(TAG, e.getMessage());
                System.exit(-1);
            }
        }

    } catch (ParseException e) {
        System.out.println(e.getMessage());
        Log.e(TAG, e.getMessage());
        System.exit(-1);
    }
}

From source file:org.n52.oss.testdata.sml.GeneratorClient.java

/**
 * @param args/*from   w  w w  .  ja v  a  2  s.com*/
 */
public static void main(String[] args) {
    if (sending)
        log.info("Starting insertion of test sensors into " + sirURL);
    else
        log.warn("Starting generation of test sensors, NOT sending!");

    TestSensorFactory factory = new TestSensorFactory();

    // create sensors
    List<TestSensor> sensors = new ArrayList<TestSensor>();

    for (int i = 0; i < nSensorsToGenerate; i++) {
        TestSensor s = factory.createRandomTestSensor();
        sensors.add(s);
        log.info("Added new random sensor: " + s);
    }

    ArrayList<String> insertedSirIds = new ArrayList<String>();

    // insert sensors to service
    int startOfSubList = 0;
    int endOfSubList = nSensorsInOneInsertRequest;
    while (endOfSubList <= sensors.size() + nSensorsInOneInsertRequest) {
        List<TestSensor> currentSensors = sensors.subList(startOfSubList,
                Math.min(endOfSubList, sensors.size()));

        if (currentSensors.isEmpty())
            break;

        try {
            String[] insertedSirIDs = insertSensorsInSIR(currentSensors);
            if (insertedSirIDs == null) {
                log.error("Did not insert dummy sensors.");
            } else {
                insertedSirIds.addAll(Arrays.asList(insertedSirIDs));
            }
        } catch (HttpException e) {
            log.error("Error inserting sensors.", e);
        } catch (IOException e) {
            log.error("Error inserting sensors.", e);
        }

        startOfSubList = Math.min(endOfSubList, sensors.size());
        endOfSubList = endOfSubList + nSensorsInOneInsertRequest;

        if (sending) {
            try {
                if (log.isDebugEnabled())
                    log.debug("Sleeping for " + SLEEP_BETWEEN_REQUESTS + " msecs.");
                Thread.sleep(SLEEP_BETWEEN_REQUESTS);
            } catch (InterruptedException e) {
                log.error("Interrupted!", e);
            }
        }
    }

    log.info("Added sensors (ids in sir): " + Arrays.toString(insertedSirIds.toArray()));
}

From source file:eu.cognitum.readandwrite.App.java

public static void main(String[] args) {
    try {/* w ww. j  a  va 2  s. c o  m*/
        String configFile = 0 == args.length ? "example.properties" : args[0];

        CONFIGURATION = new Properties();
        File f = new File(configFile);
        if (!f.exists()) {
            LOGGER.warning("configuration not found at " + configFile);
            return;
        }
        LOGGER.info("loading configuration file " + f.getAbsoluteFile());
        CONFIGURATION.load(new FileInputStream(f));

        String ip = CONFIGURATION.getProperty(PROP_STORAGE_HOSTNAME);
        String keyspace = CONFIGURATION.getProperty(PROP_STORAGE_KEYSPACE);
        String directory = CONFIGURATION.getProperty(PROP_STORAGE_DIRECTORY);

        // N of articles to be generated.
        int Narticles = 100000;
        // size of the buffer to commit each time
        int commitBufferSize = 100;
        // N of articles to commit before trying reads
        int readStep = 100;

        String currentNamespace = "http://mynamespace#";
        LOGGER.log(Level.INFO, "Generating the rdf...");
        GenerateRdf rdfGenerator = new GenerateRdf(currentNamespace, "tmp.rdf");
        rdfGenerator.generateAndSaveRdf(Narticles);
        LOGGER.log(Level.INFO, "Generated the rdf!");
        ArrayList<SimulateReadAndWrite> simulateAll = new ArrayList<SimulateReadAndWrite>();

        int Ndbs = 0;

        DBS[] chosenDbs = { DBS.NATIVE };
        //DBS[] chosenDbs = DBS.values();

        for (DBS dbs : chosenDbs) {
            SailRepository sr;

            switch (dbs) {
            case NATIVE:
                sr = createNativeStoreConnection(directory);
                break;
            case TITAN:
                sr = createTitanConnection(ip, keyspace);
                break;
            case NEO4J:
                sr = createNeo4jConnection(keyspace);
                break;
            case ORIENT:
                sr = createOrientConnection(keyspace);
                break;
            default:
                sr = null;
                break;
            }

            if (sr == null) {
                throw new Exception("Something wrong while connecting to " + dbs.toString());
            }

            simulateAll.add(new SimulateReadAndWrite(sr, "test" + dbs.toString(), Narticles, readStep,
                    commitBufferSize, dbs.toString(), keyspace, currentNamespace, rdfGenerator));

            simulateAll.get(Ndbs).start();
            Ndbs++;
        }

        int Nfinished = 0;
        int k;
        while (Nfinished != Ndbs) {
            Nfinished = 0;
            k = 0;
            for (DBS dbs : chosenDbs) {
                if (simulateAll.get(k).IsProcessCompleted()) {
                    Nfinished++;
                } else {
                    System.out.println(String.format("Process for db %s is at %.2f", dbs.toString(),
                            simulateAll.get(k).GetProgress()));
                }
                k++;
            }
            Thread.sleep(10000);
        }

    } catch (Exception ex) {
        LOGGER.log(Level.SEVERE, null, ex);
    }
}

From source file:Snippet141.java

public static void main(String[] args) {
    display = new Display();
    shell = new Shell(display);
    shell.setSize(300, 300);//from   w w  w  .  j a  v a 2 s. c om
    shell.open();
    shellGC = new GC(shell);
    shellBackground = shell.getBackground();

    FileDialog dialog = new FileDialog(shell);
    dialog.setFilterExtensions(new String[] { "*.gif" });
    String fileName = dialog.open();
    if (fileName != null) {
        loader = new ImageLoader();
        try {
            imageDataArray = loader.load(fileName);
            if (imageDataArray.length > 1) {
                animateThread = new Thread("Animation") {
                    public void run() {
                        /* Create an off-screen image to draw on, and fill it with the shell background. */
                        Image offScreenImage = new Image(display, loader.logicalScreenWidth,
                                loader.logicalScreenHeight);
                        GC offScreenImageGC = new GC(offScreenImage);
                        offScreenImageGC.setBackground(shellBackground);
                        offScreenImageGC.fillRectangle(0, 0, loader.logicalScreenWidth,
                                loader.logicalScreenHeight);

                        try {
                            /* Create the first image and draw it on the off-screen image. */
                            int imageDataIndex = 0;
                            ImageData imageData = imageDataArray[imageDataIndex];
                            if (image != null && !image.isDisposed())
                                image.dispose();
                            image = new Image(display, imageData);
                            offScreenImageGC.drawImage(image, 0, 0, imageData.width, imageData.height,
                                    imageData.x, imageData.y, imageData.width, imageData.height);

                            /* Now loop through the images, creating and drawing each one
                             * on the off-screen image before drawing it on the shell. */
                            int repeatCount = loader.repeatCount;
                            while (loader.repeatCount == 0 || repeatCount > 0) {
                                switch (imageData.disposalMethod) {
                                case SWT.DM_FILL_BACKGROUND:
                                    /* Fill with the background color before drawing. */
                                    Color bgColor = null;
                                    if (useGIFBackground && loader.backgroundPixel != -1) {
                                        bgColor = new Color(display,
                                                imageData.palette.getRGB(loader.backgroundPixel));
                                    }
                                    offScreenImageGC.setBackground(bgColor != null ? bgColor : shellBackground);
                                    offScreenImageGC.fillRectangle(imageData.x, imageData.y, imageData.width,
                                            imageData.height);
                                    if (bgColor != null)
                                        bgColor.dispose();
                                    break;
                                case SWT.DM_FILL_PREVIOUS:
                                    /* Restore the previous image before drawing. */
                                    offScreenImageGC.drawImage(image, 0, 0, imageData.width, imageData.height,
                                            imageData.x, imageData.y, imageData.width, imageData.height);
                                    break;
                                }

                                imageDataIndex = (imageDataIndex + 1) % imageDataArray.length;
                                imageData = imageDataArray[imageDataIndex];
                                image.dispose();
                                image = new Image(display, imageData);
                                offScreenImageGC.drawImage(image, 0, 0, imageData.width, imageData.height,
                                        imageData.x, imageData.y, imageData.width, imageData.height);

                                /* Draw the off-screen image to the shell. */
                                shellGC.drawImage(offScreenImage, 0, 0);

                                /* Sleep for the specified delay time (adding commonly-used slow-down fudge factors). */
                                try {
                                    int ms = imageData.delayTime * 10;
                                    if (ms < 20)
                                        ms += 30;
                                    if (ms < 30)
                                        ms += 10;
                                    Thread.sleep(ms);
                                } catch (InterruptedException e) {
                                }

                                /* If we have just drawn the last image, decrement the repeat count and start again. */
                                if (imageDataIndex == imageDataArray.length - 1)
                                    repeatCount--;
                            }
                        } catch (SWTException ex) {
                            System.out.println("There was an error animating the GIF");
                        } finally {
                            if (offScreenImage != null && !offScreenImage.isDisposed())
                                offScreenImage.dispose();
                            if (offScreenImageGC != null && !offScreenImageGC.isDisposed())
                                offScreenImageGC.dispose();
                            if (image != null && !image.isDisposed())
                                image.dispose();
                        }
                    }
                };
                animateThread.setDaemon(true);
                animateThread.start();
            }
        } catch (SWTException ex) {
            System.out.println("There was an error loading the GIF");
        }
    }

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:eqtlmappingpipeline.util.ModuleEqtlGeuvadisReplication.java

/**
 * @param args the command line arguments
 *///w  w w  .j  a va2 s  .c  o m
public static void main(String[] args) throws IOException, LdCalculatorException {

    System.out.println(HEADER);
    System.out.println();
    System.out.flush(); //flush to make sure header is before errors
    try {
        Thread.sleep(25); //Allows flush to complete
    } catch (InterruptedException ex) {
    }

    CommandLineParser parser = new PosixParser();
    final CommandLine commandLine;
    try {
        commandLine = parser.parse(OPTIONS, args, true);
    } catch (ParseException ex) {
        System.err.println("Invalid command line arguments: " + ex.getMessage());
        System.err.println();
        new HelpFormatter().printHelp(" ", OPTIONS);
        System.exit(1);
        return;
    }

    final String[] genotypesBasePaths = commandLine.getOptionValues("g");
    final RandomAccessGenotypeDataReaderFormats genotypeDataType;
    final String replicationQtlFilePath = commandLine.getOptionValue("e");
    final String interactionQtlFilePath = commandLine.getOptionValue("i");
    final String outputFilePath = commandLine.getOptionValue("o");
    final double ldCutoff = Double.parseDouble(commandLine.getOptionValue("ld"));
    final int window = Integer.parseInt(commandLine.getOptionValue("w"));

    System.out.println("Genotype: " + Arrays.toString(genotypesBasePaths));
    System.out.println("Interaction file: " + interactionQtlFilePath);
    System.out.println("Replication file: " + replicationQtlFilePath);
    System.out.println("Output: " + outputFilePath);
    System.out.println("LD: " + ldCutoff);
    System.out.println("Window: " + window);

    try {
        if (commandLine.hasOption("G")) {
            genotypeDataType = RandomAccessGenotypeDataReaderFormats
                    .valueOf(commandLine.getOptionValue("G").toUpperCase());
        } else {
            if (genotypesBasePaths[0].endsWith(".vcf")) {
                System.err.println(
                        "Only vcf.gz is supported. Please see manual on how to do create a vcf.gz file.");
                System.exit(1);
                return;
            }
            try {
                genotypeDataType = RandomAccessGenotypeDataReaderFormats
                        .matchFormatToPath(genotypesBasePaths[0]);
            } catch (GenotypeDataException e) {
                System.err
                        .println("Unable to determine input 1 type based on specified path. Please specify -G");
                System.exit(1);
                return;
            }
        }
    } catch (IllegalArgumentException e) {
        System.err.println("Error parsing --genotypesFormat \"" + commandLine.getOptionValue("G")
                + "\" is not a valid input data format");
        System.exit(1);
        return;
    }

    final RandomAccessGenotypeData genotypeData;

    try {
        genotypeData = genotypeDataType.createFilteredGenotypeData(genotypesBasePaths, 100, null, null, null,
                0.8);
    } catch (TabixFileNotFoundException e) {
        LOGGER.fatal("Tabix file not found for input data at: " + e.getPath() + "\n"
                + "Please see README on how to create a tabix file");
        System.exit(1);
        return;
    } catch (IOException e) {
        LOGGER.fatal("Error reading input data: " + e.getMessage(), e);
        System.exit(1);
        return;
    } catch (IncompatibleMultiPartGenotypeDataException e) {
        LOGGER.fatal("Error combining the impute genotype data files: " + e.getMessage(), e);
        System.exit(1);
        return;
    } catch (GenotypeDataException e) {
        LOGGER.fatal("Error reading input data: " + e.getMessage(), e);
        System.exit(1);
        return;
    }

    ChrPosTreeMap<ArrayList<EQTL>> replicationQtls = new QTLTextFile(replicationQtlFilePath, false)
            .readQtlsAsTreeMap();

    int interactionSnpNotInGenotypeData = 0;
    int noReplicationQtlsInWindow = 0;
    int noReplicationQtlsInLd = 0;
    int multipleReplicationQtlsInLd = 0;
    int replicationTopSnpNotInGenotypeData = 0;

    final CSVWriter outputWriter = new CSVWriter(new FileWriter(new File(outputFilePath)), '\t', '\0');
    final String[] outputLine = new String[14];
    int c = 0;
    outputLine[c++] = "Chr";
    outputLine[c++] = "Pos";
    outputLine[c++] = "SNP";
    outputLine[c++] = "Gene";
    outputLine[c++] = "Module";
    outputLine[c++] = "DiscoveryZ";
    outputLine[c++] = "ReplicationZ";
    outputLine[c++] = "DiscoveryZCorrected";
    outputLine[c++] = "ReplicationZCorrected";
    outputLine[c++] = "DiscoveryAlleleAssessed";
    outputLine[c++] = "ReplicationAlleleAssessed";
    outputLine[c++] = "bestLd";
    outputLine[c++] = "bestLd_dist";
    outputLine[c++] = "nextLd";
    outputWriter.writeNext(outputLine);

    HashSet<String> notFound = new HashSet<>();

    CSVReader interactionQtlReader = new CSVReader(new FileReader(interactionQtlFilePath), '\t');
    interactionQtlReader.readNext();//skip header
    String[] interactionQtlLine;
    while ((interactionQtlLine = interactionQtlReader.readNext()) != null) {

        String snp = interactionQtlLine[1];
        String chr = interactionQtlLine[2];
        int pos = Integer.parseInt(interactionQtlLine[3]);
        String gene = interactionQtlLine[4];
        String alleleAssessed = interactionQtlLine[9];
        String module = interactionQtlLine[12];
        double discoveryZ = Double.parseDouble(interactionQtlLine[10]);

        GeneticVariant interactionQtlVariant = genotypeData.getSnpVariantByPos(chr, pos);

        if (interactionQtlVariant == null) {
            System.err.println("Interaction QTL SNP not found in genotype data: " + chr + ":" + pos);
            ++interactionSnpNotInGenotypeData;
            continue;
        }

        EQTL bestMatch = null;
        double bestMatchR2 = Double.NaN;
        Ld bestMatchLd = null;
        double nextBestR2 = Double.NaN;

        ArrayList<EQTL> sameSnpQtls = replicationQtls.get(chr, pos);

        if (sameSnpQtls != null) {
            for (EQTL sameSnpQtl : sameSnpQtls) {
                if (sameSnpQtl.getProbe().equals(gene)) {
                    bestMatch = sameSnpQtl;
                    bestMatchR2 = 1;
                }
            }
        }

        NavigableMap<Integer, ArrayList<EQTL>> potentionalReplicationQtls = replicationQtls.getChrRange(chr,
                pos - window, true, pos + window, true);

        for (ArrayList<EQTL> potentialReplicationQtls : potentionalReplicationQtls.values()) {

            for (EQTL potentialReplicationQtl : potentialReplicationQtls) {

                if (!potentialReplicationQtl.getProbe().equals(gene)) {
                    continue;
                }

                GeneticVariant potentialReplicationQtlVariant = genotypeData.getSnpVariantByPos(
                        potentialReplicationQtl.getRsChr().toString(), potentialReplicationQtl.getRsChrPos());

                if (potentialReplicationQtlVariant == null) {
                    notFound.add(potentialReplicationQtl.getRsChr().toString() + ":"
                            + potentialReplicationQtl.getRsChrPos());
                    ++replicationTopSnpNotInGenotypeData;
                    continue;
                }

                Ld ld = interactionQtlVariant.calculateLd(potentialReplicationQtlVariant);
                double r2 = ld.getR2();

                if (r2 > 1) {
                    r2 = 1;
                }

                if (bestMatch == null) {
                    bestMatch = potentialReplicationQtl;
                    bestMatchR2 = r2;
                    bestMatchLd = ld;
                } else if (r2 > bestMatchR2) {
                    bestMatch = potentialReplicationQtl;
                    nextBestR2 = bestMatchR2;
                    bestMatchR2 = r2;
                    bestMatchLd = ld;
                }

            }
        }

        double replicationZ = Double.NaN;
        double replicationZCorrected = Double.NaN;
        double discoveryZCorrected = Double.NaN;

        String replicationAlleleAssessed = null;

        if (bestMatch != null) {
            replicationZ = bestMatch.getZscore();
            replicationAlleleAssessed = bestMatch.getAlleleAssessed();

            if (pos != bestMatch.getRsChrPos()) {

                String commonHap = null;
                double commonHapFreq = -1;
                for (Map.Entry<String, Double> hapFreq : bestMatchLd.getHaplotypesFreq().entrySet()) {

                    double f = hapFreq.getValue();

                    if (f > commonHapFreq) {
                        commonHapFreq = f;
                        commonHap = hapFreq.getKey();
                    }

                }

                String[] commonHapAlleles = StringUtils.split(commonHap, '/');

                discoveryZCorrected = commonHapAlleles[0].equals(alleleAssessed) ? discoveryZ : discoveryZ * -1;
                replicationZCorrected = commonHapAlleles[1].equals(replicationAlleleAssessed) ? replicationZ
                        : replicationZ * -1;

            } else {

                discoveryZCorrected = discoveryZ;
                replicationZCorrected = alleleAssessed.equals(replicationAlleleAssessed) ? replicationZ
                        : replicationZ * -1;

            }

        }

        c = 0;
        outputLine[c++] = chr;
        outputLine[c++] = String.valueOf(pos);
        outputLine[c++] = snp;
        outputLine[c++] = gene;
        outputLine[c++] = module;
        outputLine[c++] = String.valueOf(discoveryZ);
        outputLine[c++] = bestMatch == null ? "NA" : String.valueOf(replicationZ);
        outputLine[c++] = bestMatch == null ? "NA" : String.valueOf(discoveryZCorrected);
        outputLine[c++] = bestMatch == null ? "NA" : String.valueOf(replicationZCorrected);
        outputLine[c++] = alleleAssessed;
        outputLine[c++] = bestMatch == null ? "NA" : String.valueOf(bestMatch.getAlleleAssessed());
        outputLine[c++] = String.valueOf(bestMatchR2);
        outputLine[c++] = bestMatch == null ? "NA" : String.valueOf(Math.abs(pos - bestMatch.getRsChrPos()));
        outputLine[c++] = String.valueOf(nextBestR2);
        outputWriter.writeNext(outputLine);

    }

    outputWriter.close();

    for (String e : notFound) {
        System.err.println("Not found: " + e);
    }

    System.out.println("interactionSnpNotInGenotypeData: " + interactionSnpNotInGenotypeData);
    System.out.println("noReplicationQtlsInWindow: " + noReplicationQtlsInWindow);
    System.out.println("noReplicationQtlsInLd: " + noReplicationQtlsInLd);
    System.out.println("multipleReplicationQtlsInLd: " + multipleReplicationQtlsInLd);
    System.out.println("replicationTopSnpNotInGenotypeData: " + replicationTopSnpNotInGenotypeData);

}

From source file:com.twitter.hraven.hadoopJobMonitor.jmx.WhiteList.java

public static void main(String[] args) throws Exception {
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    ObjectName name = new ObjectName("com.twitter.hraven.hadoopJobMonitor.jmx:type=WhiteList");
    WhiteList.init("/tmp");
    WhiteList mbean = WhiteList.getInstance();
    mbs.registerMBean(mbean, name);/*  w  w  w.  j ava  2s  .  c o m*/
    System.out.println("Waiting forever...");
    Thread.sleep(Long.MAX_VALUE);
}

From source file:com.balero.test.Wizard.java

public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    System.out.println(""
            + ".-. .-')     ('-.                 ('-.  _  .-')                                _   .-')      .-')    \n"
            + "\\  ( OO )   ( OO ).-.           _(  OO)( \\( -O )                              ( '.( OO )_   ( OO ). \n"
            + " ;-----.\\   / . --. / ,--.     (,------.,------.  .-'),-----.          .-----. ,--.   ,--.)(_)---\\_) \n"
            + " | .-.  |   | \\-.  \\  |  |.-')  |  .---'|   /`. '( OO'  .-.  '        '  .--./ |   `.'   | /    _ |  \n"
            + " | '-' /_).-'-'  |  | |  | OO ) |  |    |  /  | |/   |  | |  |        |  |('-. |         | \\  :` `.  \n"
            + " | .-. `.  \\| |_.'  | |  |`-' |(|  '--. |  |_.' |\\_) |  |\\|  |       /_) |OO  )|  |'.'|  |  '..`''.) \n"
            + " | |  \\  |  |  .-.  |(|  '---.' |  .--' |  .  '.'  \\ |  | |  |       ||  |`-'| |  |   |  | .-._)   \\ \n"
            + " | '--'  /  |  | |  | |      |  |  `---.|  |\\  \\    `'  '-'  '      (_'  '--'\\ |  |   |  | \\       / \n"
            + " `------'   `--' `--' `------'  `------'`--' '--'     `-----'          `-----' `--'   `--'  `-----'  \n"
            + "                                                                                  Enterprise Edition\n");
    System.out.println("Welcome to Balero CMS Setup Wizard\n");
    System.out.println("Provide your Database configuration.\n");

    String dbuser;//from   w  ww.  j  av  a2  s . c  o  m
    System.out.print("Insert MySQL Username\n");
    dbuser = sc.nextLine();

    String dbpass;
    System.out.print("Insert MySQL Password\n");
    dbpass = sc.nextLine();

    String opt;
    System.out.println("The MIT License (MIT)\n" + "\n" + "Copyright (c) 2014 Balero CMS Enterprise Edition.\n"
            + "\n" + "Permission is hereby granted, free of charge, to any person obtaining a copy\n"
            + "of this software and associated documentation files (the \"Software\"), to deal\n"
            + "in the Software without restriction, including without limitation the rights\n"
            + "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n"
            + "copies of the Software, and to permit persons to whom the Software is\n"
            + "furnished to do so, subject to the following conditions:\n" + "\n"
            + "The above copyright notice and this permission notice shall be included in\n"
            + "all copies or substantial portions of the Software.\n" + "\n"
            + "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n"
            + "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n"
            + "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n"
            + "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n"
            + "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n"
            + "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n" + "THE SOFTWARE.\n"
            + "Agree: Enter Decline: e");
    opt = sc.nextLine();
    exitWizard(opt);

    System.out.print("Setup wizard will create database tables\n" + "Continue: Enter or Exit: e\n");
    opt = sc.nextLine();
    exitWizard(opt);

    try {

        System.out.println("" + "     _( )_          _      Mounting CMS...\n" + "   _(     )_      _( )_\n"
                + "  (_________)   _(     )_\n" + "               (_________)\n"
                + "    0  1  0               \n" + "       1  0     0  1  0\n" + "          1       1  0");
        ;

        for (double progressPercentage = 0.0; progressPercentage < 1.0; progressPercentage += 0.01) {
            updateProgress(progressPercentage);
            Thread.sleep(100);
        }
    } catch (InterruptedException e) {

    }

}