List of usage examples for java.lang Thread sleep
public static native void sleep(long millis) throws InterruptedException;
From source file:com.netflix.suro.client.example.SuroClient4Test.java
public static void main(String[] args) throws JsonProcessingException, InterruptedException { // ip num_of_messages message_size sleep num_of_iterations String ip = args[0];//from w w w .j a v a 2 s.c o m int numMessages = Integer.parseInt(args[1]); int messageSize = Integer.parseInt(args[2]); int sleep = Integer.parseInt(args[3]); int numIterations = Integer.parseInt(args[4]); Properties props = new Properties(); props.setProperty(ClientConfig.LB_TYPE, "static"); props.setProperty(ClientConfig.LB_SERVER, ip); SuroClient client = new SuroClient(props); byte[] payload = createMessagePayload(messageSize); for (int n = 0; n < numIterations; ++n) { for (int i = 0; i < numMessages; ++i) { client.send(new Message(i % 2 == 0 ? "request_trace" : "nf_errors_log", payload)); } Thread.sleep(sleep); } client.shutdown(); }
From source file:com.google.developers.gdgfirenze.mockep.AndroidSimulator.java
public static void main(String[] args) throws InterruptedException { for (int i = 0; i < 10000; i++) { try {/*from w w w . j av a 2s . c o m*/ Thread.sleep(5000); JSONObject data = createJsonUpdatePacket(); postData("http://localhost:10080/sensormixSamplesEndpoint", data); } catch (JSONException | IOException e) { System.out.println("Error on sending sample: " + e.getMessage()); } } }
From source file:com.newlandframework.avatarmq.test.AvatarMQProducer1.java
public static void main(String[] args) throws InterruptedException { AvatarMQProducer producer = new AvatarMQProducer("127.0.0.1:18888", "AvatarMQ-Topic-1"); producer.setClusterId("AvatarMQCluster"); producer.init();/* w w w.j av a2 s . co m*/ producer.start(); System.out.println(StringUtils.center("AvatarMQProducer1 ???", 50, "*")); for (int i = 0; i < 1; i++) { Message message = new Message(); String str = "Hello AvatarMQ From Producer1[" + i + "]"; message.setBody(str.getBytes()); ProducerAckMessage result = producer.delivery(message); if (result.getStatus() == (ProducerAckMessage.SUCCESS)) { System.out.printf("AvatarMQProducer1 ????:%s\n", result.getMsgId()); } Thread.sleep(100); } producer.shutdown(); System.out.println(StringUtils.center("AvatarMQProducer1 ???", 50, "*")); }
From source file:com.jbrisbin.vcloud.cache.Bootstrap.java
public static void main(String[] args) { CommandLineParser parser = new BasicParser(); CommandLine cmdLine = null;/*from w w w.ja v a 2 s . co m*/ try { cmdLine = parser.parse(opts, args); } catch (ParseException e) { log.error(e.getMessage(), e); } String configFile = "/etc/cloud/async-cache.xml"; if (null != cmdLine) { if (cmdLine.hasOption('c')) { configFile = cmdLine.getOptionValue('c'); } } ApplicationContext context = new FileSystemXmlApplicationContext(configFile); RabbitMQAsyncCacheProvider cacheProvider = context.getBean(RabbitMQAsyncCacheProvider.class); while (cacheProvider.isActive()) { try { Thread.sleep(3000); } catch (InterruptedException e) { log.error(e.getMessage(), e); } } }
From source file:com.newlandframework.avatarmq.test.AvatarMQProducer2.java
public static void main(String[] args) throws InterruptedException { AvatarMQProducer producer = new AvatarMQProducer("127.0.0.1:18888", "AvatarMQ-Topic-2"); producer.setClusterId("AvatarMQCluster2"); producer.init();/*from w ww . j av a2 s .com*/ producer.start(); System.out.println(StringUtils.center("AvatarMQProducer2 ???", 50, "*")); for (int i = 0; i < 100; i++) { Message message = new Message(); String str = "Hello AvatarMQ From Producer2[" + i + "]"; message.setBody(str.getBytes()); ProducerAckMessage result = producer.delivery(message); if (result.getStatus() == (ProducerAckMessage.SUCCESS)) { System.out.printf("AvatarMQProducer2 ????:%s\n", result.getMsgId()); } Thread.sleep(100); } producer.shutdown(); System.out.println(StringUtils.center("AvatarMQProducer2 ???", 50, "*")); }
From source file:TransitionDetectorMain.java
public static void main(String[] args) { try {//from w w w. ja v a2s .com TransitionDetector td = new TransitionDetector(false); Thread threadA = startTrueWaiter(td, "threadA"); Thread threadB = startFalseWaiter(td, "threadB"); Thread.sleep(200); print("td=" + td + ", about to set to 'false'"); td.setValue(false); Thread.sleep(200); print("td=" + td + ", about to set to 'true'"); td.setValue(true); Thread.sleep(200); print("td=" + td + ", about to pulse value"); td.pulseValue(); Thread.sleep(200); threadA.interrupt(); threadB.interrupt(); } catch (InterruptedException x) { x.printStackTrace(); } }
From source file:com.taobao.tddl.common.DynamicLogTest.java
public static void main(String[] args) throws InterruptedException { MockServer.setUpMockServer();// ww w . j a v a 2 s .co m DynamicLog dynamicLog = DynamicLog.getInstance("test"); new Thread(new Runnable() { @Override public void run() { for (int i = 0; i < 300; i++) { try { Thread.sleep(1000); } catch (InterruptedException e) { } MockServer.setConfigInfo("com.taobao.tddl.v1_test_buryPoints", getSpringXmlString("test", // i + "+ 'th:date='+(java.util.Date)args[0]")); } } }).start(); for (int i = 0; i < 300; i++) { dynamicLog.warn("test", new Object[] { new Date() }, "defaultLog", log); Thread.sleep(1000); } MockServer.tearDownMockServer(); }
From source file:org.apache.camel.example.mail.MailDslExamples.java
public static void main(final String[] args) throws Exception { AbstractApplicationContext context = new ClassPathXmlApplicationContext( "META-INF/spring/camel-context.xml"); // get the camel template for Spring template style sending of messages (= producer) final ProducerTemplate producer = context.getBean("camelTemplate", ProducerTemplate.class); producer.sendBodyAndHeader("direct:sendSmtpMail", "Test mail from smtp", "subject", "First Test Mail with content type"); // send mail with password encrypted in properties file jasypt producer.sendBodyAndHeader("direct:sendSmtpMailEncryptedPassword", "Test mail from smtp", "subject", "First Test Mail with content type"); // Keep running as listener need to be up for receiving messages. Thread.sleep(10000000); // IOHelper.close(context); }
From source file:fr.logfiletoes.Main.java
public static void main(String[] args) throws IOException { String configFile = getConfigFilePath(); LOG.log(Level.INFO, "Load config file \"{0}\"", configFile); Config config = new Config(configFile); LOG.info("Config file OK"); for (Unit unit : config.getUnits()) { unit.start();//from w w w. j ava 2s . co m } while (true) { try { Thread.sleep(1000); } catch (InterruptedException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:KeyEventPost.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); final Text text = new Text(shell, SWT.BORDER); text.setSize(text.computeSize(150, SWT.DEFAULT)); shell.pack();/*from w w w . j a va2s .c o m*/ shell.open(); new Thread() { public void run() { String string = "Love the method."; for (int i = 0; i < string.length(); i++) { char ch = string.charAt(i); boolean shift = Character.isUpperCase(ch); ch = Character.toLowerCase(ch); if (shift) { Event event = new Event(); event.type = SWT.KeyDown; event.keyCode = SWT.SHIFT; display.post(event); } Event event = new Event(); event.type = SWT.KeyDown; event.character = ch; display.post(event); try { Thread.sleep(10); } catch (InterruptedException e) { } event.type = SWT.KeyUp; display.post(event); try { Thread.sleep(100); } catch (InterruptedException e) { } if (shift) { event = new Event(); event.type = SWT.KeyUp; event.keyCode = SWT.SHIFT; display.post(event); } } } }.start(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }