List of usage examples for java.lang Thread sleep
public static native void sleep(long millis) throws InterruptedException;
From source file:com.villemos.ispace.Starter.java
public static void main(String[] args) { System.out.println("Starting iSpace."); try {// www .ja v a2 s .c o m /** Read the configuration file as the first argument. If not set, then we try the default name. */ String assemblyFile = System.getProperty("ispace.assembly") == null ? "assembly.xml" : System.getProperty("ispace.assembly"); System.out.println("Using assembly file " + assemblyFile); new FileSystemXmlApplicationContext(assemblyFile); while (true) { try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:name.chengchao.myhttpclient.version3_1.HttpClient3Util.java
public static void main(String[] args) throws Exception { for (int i = 0; i < 10; i++) { String result = getDataAsStringFromUrl("http://www.chengchao.name/css/style.css"); System.out.println(result); Thread.sleep(2000); }/*www .j a va 2s . c o m*/ Thread.sleep(1000000); }
From source file:be.error.rpi.test.UdpTest.java
public static void main(String[] args) throws Exception { final InetAddress IPAddress = InetAddress.getByName("192.168.0.10"); final DatagramSocket clientSocket = new DatagramSocket(); new Thread() { @Override//from ww w. j av a 2s . co m public void run() { try { while (true) { String s = "0:0:0:"; DatagramPacket sendPacket = new DatagramPacket(s.getBytes(), s.getBytes().length, IPAddress, 8000); clientSocket.send(sendPacket); Thread.sleep(100); } } catch (Exception e) { } } }.start(); new Thread() { @Override public void run() { try { while (true) { String s = "1:1:1:"; DatagramPacket sendPacket = new DatagramPacket(s.getBytes(), s.getBytes().length, IPAddress, 8000); clientSocket.send(sendPacket); Thread.sleep(100); } } catch (Exception e) { } } }.start(); }
From source file:cz.cuni.mff.d3s.spl.example.newton.app.Main.java
public static void main(String[] args) { try {//w w w. java 2 s. c om System.out.printf("Letting things settle down before actual computation.\n"); Thread.sleep(1000 * 1); } catch (InterruptedException ignored) { } /* This seed gives reasonable data, keep it at that ;-). */ Random random = new Random(2); double[] coefficients = generateCoefficients(random); PolynomialFunction function = new PolynomialFunction(coefficients); NewtonSolver solver = new NewtonSolver(); System.out.printf("Will solve polynomial function of degree %d.\n", function.degree()); inspectClass(solver); try { for (int i = 0; i < WARM_UP_LOOPS; i++) { double result = solver.solve(10000, function, -1000, 1000); } long startTimeNanos = System.nanoTime(); for (int i = 0; i < MEASURED_LOOPS; i++) { double result = solver.solve(10000, function, -1000, 1000); } long endTimeNanos = System.nanoTime(); long runTimeNanos = endTimeNanos - startTimeNanos; long runTimeMillis = runTimeNanos / (1000 * 1000); System.out.printf("%d loops of solving took %dns (%dms).\n", MEASURED_LOOPS, runTimeNanos, runTimeMillis); } catch (MaxIterationsExceededException e) { e.printStackTrace(); } catch (FunctionEvaluationException e) { e.printStackTrace(); } inspectClass(solver); }
From source file:com.twitlinks.Main.java
/** * @param args/* w w w .j av a 2 s .c o m*/ * @throws ParseException * @throws org.apache.lucene.queryParser.ParseException * @throws IOException * @throws InterruptedException */ public static void main(String[] args) throws ParseException, IOException, org.apache.lucene.queryParser.ParseException, InterruptedException { Log log = LogFactory.getLog(Main.class); Parser parser = new Parser(true, "dataset_2m"); parser.start(); Indexer indexer = new Indexer(); indexer.start(); while (true) { try { Thread.sleep(2000); log.info(parser.getLinesRead() + ":" + indexer.docCount + ":" + Buffer.documentQueue.size()); } catch (InterruptedException e) { e.printStackTrace(); } if (!parser.isAlive() && Buffer.documentQueue.size() == 0) { log.info(parser.getLinesRead() + ":" + indexer.docCount + ":" + Buffer.documentQueue.size()); indexer.stopIndexing(); break; } } //Test the simple search, current text:fantastic SimpleSearcher searcher = new SimpleSearcher(); searcher.searcher(); }
From source file:GeneralInterrupt.java
public static void main(String[] args) { GeneralInterrupt si = new GeneralInterrupt(); Thread t = new Thread(si); t.start();//from www .j ava 2 s. co m try { Thread.sleep(2000); } catch (InterruptedException x) { } System.out.println("in main() - interrupting other thread"); t.interrupt(); System.out.println("in main() - leaving"); }
From source file:com.github.liyp.rabbitmq.demo.Main.java
public static void main(String[] args) throws IOException, InterruptedException { // start spring context @SuppressWarnings({ "resource" }) ApplicationContext context = new ClassPathXmlApplicationContext( "com/github/liyp/rabbitmq/demo/applicationContext.xml"); RabbitTemplate rabbitTemplate = (RabbitTemplate) context.getBean("rabbitTemplate"); for (int i = 0; i < 200; i++) { rabbitTemplate.convertAndSend("queue_one", "test queue 1 " + i); rabbitTemplate.convertAndSend("queue_two", new MsgBean("test queue 2 " + i)); }/*from w w w . java2s . co m*/ Thread.sleep(5000); ThreadPoolTaskExecutor threadExe = (ThreadPoolTaskExecutor) context.getBean("taskExecutor"); System.out.println(threadExe.getActiveCount()); System.out.println(threadExe.getCorePoolSize()); System.out.println(threadExe.getMaxPoolSize()); System.out.println(threadExe.getPoolSize()); System.out.println(threadExe.getThreadPoolExecutor().getCorePoolSize()); // System.out.println("rsv: " + // rabbitTemplate.receiveAndConvert("queue_two")); }
From source file:com.bt.aloha.mockphones.Main.java
public static void main(String[] args) { start(args);//from ww w .j a v a 2 s . c o m try { while (true) { Thread.sleep(1000); } } catch (Exception e) { log.error("Exception in main: " + e.getMessage(), e); } }
From source file:Producer.java
public static void main(String[] args) { BlockingDeque<Integer> deque = new LinkedBlockingDeque<Integer>(5); Runnable producer = new Producer("Producer", deque); Runnable consumer = new Consumer("Consumer", deque); new Thread(producer).start(); try {/*from ww w . j ava 2 s . c om*/ Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } new Thread(consumer).start(); }
From source file:com.surveypanel.form.FormHandler.java
public static void main(String[] args) { if (handler == null) { handler = new FormHandler(); }/*from w ww . j a v a 2s.c om*/ try { init(); while (!quit) { Thread.sleep(1000); } shutDown(); } catch (Exception e) { e.printStackTrace(); } }