List of usage examples for java.lang Thread sleep
public static native void sleep(long millis) throws InterruptedException;
From source file:org.dimitrovchi.Demo.java
public static void main(String... args) throws Exception { final String confPkgName = DemoApplicationConfiguration.class.getPackage().getName(); try (final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( confPkgName)) {/* w w w .j a v a 2 s . co m*/ LOG.info("Context " + context + " started"); context.start(); Thread.sleep(60_000L); } }
From source file:DoAudioCapture.java
public static void main(String[] args) { Location2Location capture; CaptureDeviceInfo audioDevice;/*from www .j a v a 2s . c o m*/ MediaLocator audioLocation; MediaLocator destination; audioDevice = CaptureDeviceManager.getDevice("DirectSoundCapture"); audioLocation = audioDevice.getLocator(); Format[] format = new Format[1]; format[0] = new AudioFormat(AudioFormat.LINEAR); ContentDescriptor container = new ContentDescriptor(FileTypeDescriptor.WAVE); destination = new MediaLocator("file://d:\\jmf\\book\\media\\capturedSound.wav"); capture = new Location2Location(audioLocation, destination, format, container, 1.0); System.out.println("Started recording..."); capture.setStopTime(new Time(10.0)); int waited = capture.transfer(35000); int state = capture.getState(); System.out.println("Waited " + waited + " milliseconds. State now " + state); waited /= 1000; while (state != Location2Location.FINISHED && state != Location2Location.FAILED) { try { Thread.sleep(10000); } catch (InterruptedException ie) { } System.out.println("Waited another 10 seconds, state = " + capture.getState()); waited += 10; } System.out.println("Waited a total of " + waited + " seconds"); System.exit(0); }
From source file:Main.java
public static void main(String[] args) { JProgressBar progressBar = new JProgressBar(); progressBar.setOpaque(false);// w ww . j av a 2 s . com progressBar.setUI(new GradientPalletProgressBarUI()); JPanel p = new JPanel(); p.add(progressBar); p.add(new JButton(new AbstractAction("Start") { @Override public void actionPerformed(ActionEvent e) { SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { @Override public Void doInBackground() { int current = 0, lengthOfTask = 100; while (current <= lengthOfTask && !isCancelled()) { try { Thread.sleep(50); } catch (Exception ie) { return null; } setProgress(100 * current / lengthOfTask); current++; } return null; } }; worker.addPropertyChangeListener(new ProgressListener(progressBar)); worker.execute(); } })); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.getContentPane().add(p); frame.setSize(320, 240); frame.setVisible(true); }
From source file:com.apress.prospringintegration.messagestore.jdbc.JdbcTest.java
public static void main(String[] args) throws Throwable { ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext( "classpath:spring/jdbc/spring-context.xml"); MessageProducer messageProducer = classPathXmlApplicationContext.getBean(MessageProducer.class); for (int i = 0; i < 10; i++) messageProducer.sendMessages(i,/*from w w w .j a va 2s . c o m*/ Arrays.asList(new String[] { "apple", "banana", "carrot", "date", "egg" })); Thread.sleep(1000 * 10); }
From source file:com.apress.prospringintegration.messagestore.gemfire.GemfireTest.java
public static void main(String[] args) throws Throwable { ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext( "classpath:spring/gemfire/spring-context.xml"); MessageProducer messageProducer = classPathXmlApplicationContext.getBean(MessageProducer.class); for (int i = 0; i < 10; i++) messageProducer.sendMessages(i,/*from w w w . j a va2 s .com*/ Arrays.asList(new String[] { "apple", "banana", "carrot", "date", "egg" })); Thread.sleep(1000 * 10); }
From source file:demo.jaxrs.server.BasicSpringServer.java
public static void main(String args[]) throws Exception { // Initialize the spring context and fetch our test client ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( new String[] { "classpath:server-applicationContext.xml" }); Thread.sleep(100000000); }
From source file:Main.java
public static void main(String[] args) { new Main().display(); new Thread(new Runnable() { @Override//ww w . ja v a 2 s. co m public void run() { for (int i = 0; i < 3; i++) { try { Thread.sleep(1000); System.out.println((i + 1) + "s. elapsed."); } catch (InterruptedException e) { e.printStackTrace(System.err); } } } }).start(); }
From source file:com.alibaba.dubbo.examples.version.VersionConsumer.java
public static void main(String[] args) throws Exception { String config = VersionConsumer.class.getPackage().getName().replace('.', '/') + "/version-consumer.xml"; ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config); context.start();/* www . ja v a 2 s .c o m*/ VersionService versionService = (VersionService) context.getBean("versionService"); for (int i = 0; i < 10000; i++) { String hello = versionService.sayHello("world"); System.out.println(hello); Thread.sleep(2000); } System.in.read(); }
From source file:com.apress.prospringintegration.jmx.JmxOperationGateway.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmx/operation-gateway.xml"); Map<String, Integer> parameters = new HashMap<String, Integer>(); parameters.put("p1", 5); parameters.put("p2", 7); MessageChannel request = (MessageChannel) context.getBean("request"); request.send(MessageBuilder.withPayload(parameters).build()); try {// w ww .ja v a2 s . com Thread.sleep(180000); } catch (InterruptedException e) { //do nothing } context.stop(); }
From source file:Main.java
public static void main(String args[]) throws Exception { String filename = args[0];// w w w . j av a2s . com DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF; PrintService printService = PrintServiceLookup.lookupDefaultPrintService(); DocPrintJob job = printService.createPrintJob(); PrintJobListener listener = new PrintJobAdapter() { public void printDataTransferCompleted(PrintJobEvent e) { System.out.println("Good-bye"); System.exit(0); } }; job.addPrintJobListener(listener); PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); FileInputStream fis = new FileInputStream(filename); DocAttributeSet das = new HashDocAttributeSet(); Doc doc = new SimpleDoc(fis, flavor, das); job.print(doc, pras); Thread.sleep(10000); }