List of usage examples for java.lang Thread start
public synchronized void start()
From source file:com.vangent.hieos.empi.pixpdq.loader.PIDFeedLoader.java
/** * * @param args//from ww w . jav a 2 s . c om */ public static void main(String[] args) { PIDFeedLoader pfl = new PIDFeedLoader(); long start = System.currentTimeMillis(); for (int i = 0; i < DEMOGRAPHIC_FILES.length; i++) { String demographicFile = DEMOGRAPHIC_FILES[i]; PIDFeedRunnable pidFeedRunnable = pfl.getPIDFeedRunnable(TEMPLATE, demographicFile, ENDPOINT); Thread thread = new Thread(pidFeedRunnable); thread.start(); } System.out.println(" done ... TOTAL TIME - " + (System.currentTimeMillis() - start) + "ms."); }
From source file:info.bitoo.Main.java
public static void main(String[] args) throws InterruptedException, IOException, NoSuchAlgorithmException, ClientAdapterException { CommandLineParser parser = new PosixParser(); CommandLine cmd = null;//www. ja v a2 s . c om try { cmd = parser.parse(createCommandLineOptions(), args); } catch (ParseException e) { System.err.println("Parsing failed. Reason: " + e.getMessage()); } Properties props = readConfiguration(cmd); BiToo biToo = new BiToo(props); URL torrentURL = null; if (cmd.hasOption("f")) { String parmValue = cmd.getOptionValue("f"); String torrentName = parmValue + ".torrent"; biToo.setTorrent(torrentName); } else if (cmd.hasOption("t")) { torrentURL = new URL(cmd.getOptionValue("t")); biToo.setTorrent(torrentURL); } else { return; } try { Thread main = new Thread(biToo); main.setName("BiToo"); main.start(); //wait until thread complete main.join(); } finally { biToo.destroy(); } if (biToo.isCompleted()) { System.out.println("Download completed"); System.exit(0); } else { System.out.println("Download failed"); System.exit(1); } }
From source file:ThreadDemo.java
public static void main(String args[]) { // thread created Thread t = new Thread("java2s.com thread"); // set thread priority t.setPriority(1);//ww w. jav a 2 s. co m // prints thread created System.out.println("thread = " + t); // this will call run() function t.start(); }
From source file:Test.java
public static void main(String[] args) throws Exception { Thread serverThread = new Thread(new Runnable() { @Override/*from ww w . j a va 2 s. c om*/ public void run() { serverStart(); } }); serverThread.start(); Thread clientThread = new Thread(new Runnable() { @Override public void run() { clientStart(); } }); clientThread.start(); }
From source file:com.linkedin.pinot.server.starter.FileBasedServer.java
public static void main(String[] args) throws Exception { //Process Command Line to get config and port processCommandLineArgs(args);/* w ww . j ava 2 s. com*/ LOGGER.info("Trying to build server config"); MetricsRegistry metricsRegistry = new MetricsRegistry(); ServerBuilder serverBuilder = new ServerBuilder(new File(_serverConfigPath), metricsRegistry); LOGGER.info("Trying to build InstanceDataManager"); final DataManager instanceDataManager = serverBuilder.buildInstanceDataManager(); LOGGER.info("Trying to start InstanceDataManager"); instanceDataManager.start(); // bootstrapSegments(instanceDataManager); LOGGER.info("Trying to build QueryExecutor"); final QueryExecutor queryExecutor = serverBuilder.buildQueryExecutor(instanceDataManager); final QueryScheduler queryScheduler = serverBuilder.buildQueryScheduler(queryExecutor); LOGGER.info("Trying to build RequestHandlerFactory"); RequestHandlerFactory simpleRequestHandlerFactory = serverBuilder .buildRequestHandlerFactory(queryScheduler); LOGGER.info("Trying to build NettyServer"); NettyServer nettyServer = new NettyTCPServer(_serverPort, simpleRequestHandlerFactory, null); Thread serverThread = new Thread(nettyServer); ShutdownHook shutdownHook = new ShutdownHook(nettyServer); serverThread.start(); Runtime.getRuntime().addShutdownHook(shutdownHook); }
From source file:ThreadDemo.java
public static void main(String args[]) { Thread t = new Thread(new ThreadDemo(), "java2s.com thread"); // set thread priority t.setPriority(1);/* w w w. j a v a 2 s . co m*/ // print thread created System.out.println("thread = " + t); // this will call run() function t.start(); }
From source file:org.jfree.chart.demo.BubblyBubblesDemo.java
/** * Starting point for the demonstration application. * * @param args ignored.//from w w w.j a v a 2s . c o m */ public static void main(final String[] args) { final BubblyBubblesDemo demo = new BubblyBubblesDemo(TITLE); demo.pack(); demo.setSize(800, 600); RefineryUtilities.centerFrameOnScreen(demo); demo.setVisible(true); final Thread updater = demo.new UpdaterThread(); updater.setDaemon(true); updater.start(); }
From source file:org.jfree.chart.demo.BubblyBubblesDemo2.java
/** * Starting point for the demonstration application. * * @param args ignored./*from w w w. ja v a 2 s .c o m*/ */ public static void main(final String[] args) { final BubblyBubblesDemo2 demo = new BubblyBubblesDemo2(TITLE); demo.pack(); demo.setSize(800, 600); RefineryUtilities.centerFrameOnScreen(demo); demo.setVisible(true); final Thread updater = demo.new UpdaterThread(); updater.setDaemon(true); updater.start(); }
From source file:Uncaught.java
public static void main(String[] args) { Thread thread = new Thread(new Uncaught()); thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread t, Throwable e) { e.printStackTrace();//from w w w .j a v a 2 s . c o m } }); thread.start(); }
From source file:it.polito.tellmefirst.web.rest.TMFServer.java
/** * TMF starting point. From rest directory, launch this command: * mvn exec:java -Dexec.mainClass="it.polito.temefirst.web.rest.TMFServer" -Dexec.args="<path_to_TMF_installation>/conf/server.properties" * or use the run.sh file in bin directory *///from w ww .jav a 2 s.c o m public static void main(String[] args) throws TMFConfigurationException, TMFIndexesWarmUpException, URISyntaxException, InterruptedException, IOException { LOG.debug("[main] - BEGIN"); URI serverURI = new URI("http://localhost:2222/rest/"); String configFileName = args[0]; new TMFVariables(configFileName); // XXX I put the code of IndexUtil.init() here, because, for now, I need a reference of SimpleSearchers for the Enhancer // build italian searcher Directory contextIndexDirIT = LuceneManager.pickDirectory(new File(TMFVariables.CORPUS_INDEX_IT)); LOG.info("Corpus index used for italian: " + contextIndexDirIT); LuceneManager contextLuceneManagerIT = new LuceneManager(contextIndexDirIT); contextLuceneManagerIT .setLuceneDefaultAnalyzer(new ItalianAnalyzer(Version.LUCENE_36, TMFVariables.STOPWORDS_IT)); ITALIAN_CORPUS_INDEX_SEARCHER = new SimpleSearcher(contextLuceneManagerIT); // build english searcher Directory contextIndexDirEN = LuceneManager.pickDirectory(new File(TMFVariables.CORPUS_INDEX_EN)); LOG.info("Corpus index used for english: " + contextIndexDirEN); LuceneManager contextLuceneManagerEN = new LuceneManager(contextIndexDirEN); contextLuceneManagerEN .setLuceneDefaultAnalyzer(new EnglishAnalyzer(Version.LUCENE_36, TMFVariables.STOPWORDS_EN)); ENGLISH_CORPUS_INDEX_SEARCHER = new SimpleSearcher(contextLuceneManagerEN); // build kb italian searcher String kbDirIT = TMFVariables.KB_IT; String residualKbDirIT = TMFVariables.RESIDUAL_KB_IT; ITALIAN_KB_INDEX_SEARCHER = new KBIndexSearcher(kbDirIT, residualKbDirIT); // build kb english searcher String kbDirEN = TMFVariables.KB_EN; String residualKbDirEN = TMFVariables.RESIDUAL_KB_EN; ENGLISH_KB_INDEX_SEARCHER = new KBIndexSearcher(kbDirEN, residualKbDirEN); enhancer = new Enhancer(ITALIAN_CORPUS_INDEX_SEARCHER, ENGLISH_CORPUS_INDEX_SEARCHER, ITALIAN_KB_INDEX_SEARCHER, ENGLISH_KB_INDEX_SEARCHER); italianClassifier = new Classifier("it", ITALIAN_CORPUS_INDEX_SEARCHER); englishClassifier = new Classifier("en", ENGLISH_CORPUS_INDEX_SEARCHER); //The following is adapted from DBpedia Spotlight (https://github.com/dbpedia-spotlight/dbpedia-spotlight) final Map<String, String> initParams = new HashMap<String, String>(); initParams.put("com.sun.jersey.config.property.resourceConfigClass", "com.sun.jersey.api.core." + "PackagesResourceConfig"); initParams.put("com.sun.jersey.config.property.packages", "it.polito.tellmefirst.web.rest.services"); initParams.put("com.sun.jersey.config.property.WadlGeneratorConfig", "it.polito.tellmefirst.web.rest.wadl." + "ExternalUriWadlGeneratorConfig"); SelectorThread threadSelector = GrizzlyWebContainerFactory.create(serverURI, initParams); threadSelector.start(); System.err.println("Server started in " + System.getProperty("user.dir") + " listening on " + serverURI); Thread warmUp = new Thread() { public void run() { } }; warmUp.start(); while (running) { Thread.sleep(100); } threadSelector.stopEndpoint(); System.exit(0); LOG.debug("[main] - END"); }