List of usage examples for java.lang Thread sleep
public static native void sleep(long millis) throws InterruptedException;
From source file:MyThread.java
public static void main(String args[]) throws Exception { Thread thrd = new Thread(new MyThread(), "MyThread #1"); Thread thrd2 = new Thread(new MyThread(), "MyThread #2"); thrd.start();//from w ww .j a v a 2 s. c om Thread.sleep(1000); thrd.interrupt(); thrd2.start(); Thread.sleep(4000); thrd2.interrupt(); }
From source file:MyResource.java
public static void main(String args[]) throws Exception { MyResource sObj = new MyResource(); new MyThread("MyThread", sObj); for (int i = 0; i < 10; i++) { Thread.sleep(50); System.out.print("."); }//from w w w. j a va 2 s. c o m sObj.start(); }
From source file:com.apress.prospringintegration.jmx.JmxNotificationListener.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "jmx/notification-listener.xml"); try {/*from www .j ava2 s. c om*/ Thread.sleep(180000); } catch (InterruptedException e) { //do nothing } context.stop(); }
From source file:MainClass.java
public static void main(String[] args) { MainClass ad6 = new MainClass(); try {/* w w w. ja va 2 s . c o m*/ Thread.sleep(1000); } catch (InterruptedException e) { } ad6.dumpSelectionInfo(ad6.getAccessibleContext()); }
From source file:com.apress.prospringintegration.social.xmpp.XmppInbound.java
public static void main(String[] args) throws Exception { ApplicationContext context = new ClassPathXmlApplicationContext("/spring/xmpp/xmpp-inbound.xml"); Thread.sleep(10 * 60 * 1000); }
From source file:TryThread.java
public static void main(String[] args) { Thread first = new TryThread("A ", "a ", 200L); Thread second = new TryThread("B ", "b ", 300L); Thread third = new TryThread("C ", "c ", 500L); first.start();/*from w w w. j a va 2s . com*/ second.start(); third.start(); try { Thread.sleep(3000); } catch (Exception e) { System.out.println(e); } first.interrupt(); second.interrupt(); third.interrupt(); if (first.isInterrupted()) { System.out.println("First thread has been interrupted."); } }
From source file:TextAreaViews.java
public static void main(String[] args) { try {/* ww w . j ava 2 s.co m*/ UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } JFrame f = new JFrame("Text Area Views"); JTextArea ta = new JTextArea(5, 32); ta.setText("That's one small step for man...\nOne giant leap for mankind."); f.getContentPane().add(ta); f.setSize(200, 100); f.setVisible(true); ViewDisplayer.displayViews(ta, System.out); try { Thread.sleep(30000); ViewDisplayer.displayViews(ta, System.out); } catch (InterruptedException e) { } }
From source file:SplashScreenDemo.java
public static void main(String[] args) { SplashScreen splashScreen = SplashScreen.getSplashScreen(); Dimension size = splashScreen.getSize(); int borderDim = (int) (size.height * 0.05); Graphics g = splashScreen.createGraphics(); g.setColor(Color.blue);/*from w w w .j av a2 s . c om*/ for (int i = 0; i < borderDim; i++) g.drawRect(i, i, size.width - 1 - i * 2, size.height - 1 - i * 2); FontMetrics fm = g.getFontMetrics(); int sWidth = fm.stringWidth("Initializing..."); int sHeight = fm.getHeight(); if (sWidth < size.width && 2 * sHeight < size.height) { g.setColor(Color.blue); g.drawString("Initializing...", (size.width - sWidth) / 2, size.height - 2 * sHeight); } splashScreen.update(); try { Thread.sleep(5000); } catch (InterruptedException e) { } }
From source file:com.apress.prospringintegration.social.xmpp.XmppPresenceInbound.java
public static void main(String[] args) throws Exception { ApplicationContext context = new ClassPathXmlApplicationContext("/spring/xmpp/xmpp-presence-inbound.xml"); Thread.sleep(10 * 60 * 1000); }
From source file:MyTask.java
public static void main(String[] args) { Main phone = new Main(); phone.startRinging();/*from w w w . j av a2s . c o m*/ try { System.out.println("started running..."); Thread.sleep(20000); } catch (InterruptedException e) { } phone.doIt(); }