Example usage for java.lang Thread currentThread

List of usage examples for java.lang Thread currentThread

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static native Thread currentThread();

Source Link

Document

Returns a reference to the currently executing thread object.

Usage

From source file:com.xoriant.akka.mongodb.bulkimport.main.Application.java

public static void main(String[] args) throws Exception {

    ApplicationContext ctx = new GenericXmlApplicationContext("springconfig.xml");

    final ActorSystem _system = ActorSystem.create("FileImportApp");

    final ActorRef mongoInsertionActor = _system.actorOf(Props.create(MongoInsertionActor.class, ctx)
            .withRouter(new RoundRobinPool(INSERTION_ACTOR_POOL_SIZE)));

    final ActorRef fileReaderActor = _system
            .actorOf(Props.create(FileReaderActor.class, mongoInsertionActor, BATCH_SIZE));
    String path = Thread.currentThread().getContextClassLoader().getResource("NameList.csv").getFile();
    fileReaderActor.tell(path, ActorRef.noSender());
    Thread.sleep(5000);/*  w  ww. j av a 2 s .  co  m*/
    _system.shutdown();

}

From source file:de.topobyte.jsoup.Test.java

public static void main(String[] args) throws IOException {
    HtmlBuilder builder = new HtmlBuilder();

    Element head = builder.getHead();

    String header = IOUtils.toString(
            Thread.currentThread().getContextClassLoader().getResourceAsStream("bootstrap.headers.html"));
    System.out.println(header);//from  w w  w . j  a v  a2 s . c om
    ElementUtil.appendFragment(head, header);

    Element body = builder.getBody();

    // Menu

    Menu menu = new Menu();
    body.ap(menu);

    menu.addBrand(HTML.span().appendText("Awesome"));

    menu.addMain(a("#").appendText("Products"), false);
    menu.addMain(a("#").appendText("Services"), false);
    menu.addMain(a("#").appendText("Partners"), false);

    menu.addRight(a("#").appendText("About"), false);

    // Content

    Container c = body.ac(Bootstrap.container());

    Breadcrumb breadcrumb = Bootstrap.breadcrumb();
    c.ap(breadcrumb);

    breadcrumb.addTextItem("foo");
    breadcrumb.addTextItem("bar");
    breadcrumb.addTextItem("and");
    breadcrumb.addTextItem("so on");

    c.ap(h1().inner("The headline"));

    Div div = c.ac(div("foo"));

    Element p = div.ac(p().inner("this is a paragraph in a div. "));

    System.out.println(p);
    p.ap(b().inner("bold"));
    p.appendText(" and ");
    p.ap(i().inner("italic"));
    p.appendText(" text is possible as well");
    System.out.println(p);

    div.ap(button().inner("I'm a button"));

    Document doc = builder.getDocument();
    System.out.println(doc);

    builder.write(new File("/tmp/jsoup-bootstrap.html"));
}

From source file:org.jboss.jdf.stacks.StacksFactory.java

public static void main(final String[] args) throws Exception {
    show(create());//from  w w  w . jav a2 s.co m
    show(create(StacksConfigurationBuilder
            .create(Thread.currentThread().getContextClassLoader().getResource("stacks.yaml")).build()));
}

From source file:org.helios.ember.Boot.java

/**
 * Main boot// w  w w  .j  a va 2 s  . c o m
 * @param args none
 */
public static void main(String[] args) {
    LOG.info("Booting Ember.sftp Server");
    try {
        APPCTX = new GenericXmlApplicationContext(
                new FileSystemResource("./src/main/resources/META-INF/jetty.xml"));
        LOG.info("Ember.sftp Server Up");
        Thread.currentThread().join();
    } catch (Exception ex) {
        LOG.error("Failed to boot Ember.sftp Server", ex);
        System.exit(-1);
    }
}

From source file:com.nubits.nubot.launch.toolkit.NuCMC.java

public static void main(String[] args) {
    mainThread = Thread.currentThread();

    String folderName = "NuCMC_" + System.currentTimeMillis() + "/";
    String logsFolder = Settings.LOGS_PATH + "/" + folderName;
    //Create log dir
    FilesystemUtils.mkdir(logsFolder);/* w w w  .  j a v  a2  s .  c o  m*/

    NuCMC app = new NuCMC();
    if (app.readParams(args)) {
        createShutDownHook();

        LOG.info("Launching NuCheckPrice ");
        app.exec();
    } else {
        System.exit(0);
    }
}

From source file:ymanv.forex.SockJsClientTest.java

public static void main(String[] args) throws Exception {

    WebSocketHandler eh = createWebSocketHandler();

    //startWebSocket(eh);
    startSockJs(eh);//w w w  . j  av  a 2s . c  o  m

    synchronized (Thread.currentThread()) {
        Thread.currentThread().wait();
    }
}

From source file:org.sonews.Application.java

/**
 * The main entrypoint.//from w w w  .j a v  a  2s  .  c  o m
 *
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    System.out.println(VERSION);
    Thread.currentThread().setName("Mainthread");

    // Command line arguments
    boolean async = false;
    boolean feed = false; // Enable feeding?
    boolean purger = false; // Enable message purging?
    int port = -1;

    for (int n = 0; n < args.length; n++) {
        switch (args[n]) {
        case "-async": {
            async = true;
            break;
        }
        case "-c":
        case "-config": {
            Config.inst().set(Config.LEVEL_CLI, Config.CONFIGFILE, args[++n]);
            System.out.println("Using config file " + args[n]);
            break;
        }
        case "-C":
        case "-context": {
            // FIXME: Additional context files
            n++;
            break;
        }
        case "-dumpjdbcdriver": {
            System.out.println("Available JDBC drivers:");
            Enumeration<Driver> drvs = DriverManager.getDrivers();
            while (drvs.hasMoreElements()) {
                System.out.println(drvs.nextElement());
            }
            return;
        }
        case "-feed": {
            feed = true;
            break;
        }
        case "-h":
        case "-help": {
            printArguments();
            return;
        }
        case "-p": {
            port = Integer.parseInt(args[++n]);
            break;
        }
        case "-plugin-storage": {
            System.out.println("Warning: -plugin-storage is not implemented!");
            break;
        }
        case "-purger": {
            purger = true;
            break;
        }
        case "-v":
        case "-version":
            // Simply return as the version info is already printed above
            return;
        }
    }

    ApplicationContext context = new AnnotationConfigApplicationContext(Application.class);
    context = new FileSystemXmlApplicationContext(new String[] { "sonews.xml" }, context);

    // Enable storage backend
    StorageProvider sprov = context.getBean("storageProvider", StorageProvider.class);
    StorageManager.enableProvider(sprov);

    ChannelLineBuffers.allocateDirect();

    // Add shutdown hook
    Runtime.getRuntime().addShutdownHook(new ShutdownHook());

    // Start the listening daemon
    if (port <= 0) {
        port = Config.inst().get(Config.PORT, 119);
    }

    NNTPDaemon daemon = context.getBean(NNTPDaemon.class);
    daemon.setPort(port);
    daemon.start();

    // Start Connections purger thread...
    Connections.getInstance().start();

    // Start feeds
    if (feed) {
        FeedManager.startFeeding();
    }

    if (purger) {
        Purger purgerDaemon = new Purger();
        purgerDaemon.start();
    }

    // Wait for main thread to exit (setDaemon(false))
    daemon.join();
}

From source file:sample.jetty.SampleJettyApplication.java

public static void main(String[] args) throws Exception {
    InputStream inputstream = null;
    try {/* w w w .  j  a  va 2  s .  co  m*/
        Properties pro = new Properties();
        //?????
        URL url = org.springframework.util.ResourceUtils.getURL("classpath:MySql_general.properties");
        inputstream = url.openStream();
        pro.load(inputstream);
        //new EmbedMySqlServer(pro).startup();

        String dbPath = (new File("")).getAbsolutePath() + "/db/";
        dbPath = dbPath.replaceAll("\\\\", "/");
        //???
        EmbedMySqlServer mysqldbServer = new EmbedMySqlServer(pro, dbPath /*"C:\\gfworklog\\db\\"*/);

        SampleJettyApplication.MAIN_THREAD_LOCAL.put("embedMysqlServer", mysqldbServer);

        mysqldbServer.startup();

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            inputstream.close();
        } catch (Exception ex) {
        }
    }
    System.out.println(Thread.currentThread().getName() + " ========================= " + 1
            + " =========================");
    ConfigurableApplicationContext cac = SpringApplication.run(SampleJettyApplication.class, args);

}

From source file:cn.xyz.lcg.rocketmq.quickstart.PullConsumer.java

public static void main(String[] args) throws MQClientException {
    DefaultMQPullConsumer consumer = new DefaultMQPullConsumer("simplePullConsumer");

    consumer.setNamesrvAddr("centOS1:9876");

    consumer.start();//from w ww .ja v a  2 s .  c om

    Set<MessageQueue> mqs = consumer.fetchSubscribeMessageQueues("simpleTest");
    for (MessageQueue mq : mqs) {
        // System.out.println("Consume from the queue: " + mq);
        SINGLE_MQ: while (true) {
            try {
                PullResult pullResult = consumer.pullBlockIfNotFound(mq, null, getMessageQueueOffset(mq), 32);
                // System.out.println(pullResult);
                if (CollectionUtils.isNotEmpty(pullResult.getMsgFoundList())) {
                    for (MessageExt msg : pullResult.getMsgFoundList()) {
                        System.out.println(
                                Thread.currentThread().getName() + " " + new String(msg.getBody(), "UTF-8"));
                    }
                }
                putMessageQueueOffset(mq, pullResult.getNextBeginOffset());
                switch (pullResult.getPullStatus()) {
                case FOUND:
                    break;
                case NO_MATCHED_MSG:
                    break;
                case NO_NEW_MSG:
                    break SINGLE_MQ;
                case OFFSET_ILLEGAL:
                    break;
                default:
                    break;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    consumer.shutdown();
}

From source file:com.nubits.nubot.launch.NuPriceMonitor.java

public static void main(String[] args) {
    mainThread = Thread.currentThread();
    //Load settings
    Utils.loadProperties("settings.properties");

    String folderName = "NuPriceMonitor_" + System.currentTimeMillis() + "/";
    String logsFolder = Global.settings.getProperty("log_path") + folderName;
    //Create log dir
    FileSystem.mkdir(logsFolder);
    try {//from   w w w .  j av  a2  s.co m
        NuLogger.setup(false, logsFolder);
    } catch (IOException ex) {
        LOG.severe(ex.toString());
    }

    NuPriceMonitor app = new NuPriceMonitor();
    if (app.readParams(args)) {
        createShutDownHook();
        app.init();
        LOG.fine("Launching NuCheckPrice ");
        app.exec();
    } else {
        System.exit(0);
    }
}