Example usage for java.lang Runnable Runnable

List of usage examples for java.lang Runnable Runnable

Introduction

In this page you can find the example usage for java.lang Runnable Runnable.

Prototype

Runnable

Source Link

Usage

From source file:org.excalibur.fm.configuration.Main.java

@SuppressWarnings("resource")
public static void main(String[] args) throws InterruptedException {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            "classpath*:META-INF/applicationContext.xml");

    final ProviderService providerService = context.getBean(ProviderService.class);

    configureLookAndFeel();//from  w  ww  . j  ava 2  s  .c o  m

    final JFrame frame = new JFrame();
    frame.getContentPane().add(new InstanceSelectionPanel(providerService));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //        frame.pack();
    frame.setSize(1118, 470);
    frame.setLocationRelativeTo(null);

    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            frame.setVisible(true);
        }
    });

    //        Thread.currentThread().join();
    //       context.close();
}

From source file:com.lucidtechnics.blackboard.examples.cocothemonkey.CocoTheMonkey.java

public static void main(String[] _args) throws Exception {
    try {/* www  .j a va 2  s .  c  om*/
        final Blackboard blackboard = new Blackboard();

        logger.info("Starting Coco The Monkey");
        System.out.println("Starting Coco The Monkey");

        Thread thread1 = new Thread(new Runnable() {
            public void run() {
                synchronized (blackboard) {
                    try {
                        blackboard.wait();
                    } catch (InterruptedException e) {
                    }
                }

                for (int i = 0; i < 100; i++) {
                    Monkey monkey = new Monkey("Coco-1-" + i);
                    Mango mango = new Mango("Coco-2-" + i);
                    Eagle eagle = new Eagle("Coco-3-" + i);
                    Hunter hunter = new Hunter("Coco-5-" + i);

                    blackboard.placeOnBlackboard(eagle);
                    blackboard.placeOnBlackboard(mango);
                    blackboard.placeOnBlackboard(monkey);
                    blackboard.placeOnBlackboard(hunter);
                }
            }
        });

        Thread thread2 = new Thread(new Runnable() {
            public void run() {
                synchronized (blackboard) {
                    try {
                        blackboard.wait();
                    } catch (InterruptedException e) {
                    }
                }

                for (int i = 0; i < 100; i++) {
                    Monkey monkey = new Monkey("Coco-4-" + i);
                    Mango mango = new Mango("Coco-1-" + i);
                    Eagle eagle = new Eagle("Coco-5-" + i);
                    Hunter hunter = new Hunter("Coco-3-" + i);

                    blackboard.placeOnBlackboard(eagle);
                    blackboard.placeOnBlackboard(mango);
                    blackboard.placeOnBlackboard(monkey);
                    blackboard.placeOnBlackboard(hunter);
                }
            }
        });

        Thread thread3 = new Thread(new Runnable() {
            public void run() {
                synchronized (blackboard) {
                    try {
                        blackboard.wait();
                    } catch (InterruptedException e) {
                    }
                }

                for (int i = 0; i < 100; i++) {
                    Monkey monkey = new Monkey("Coco-3-" + i);
                    Mango mango = new Mango("Coco-5-" + i);
                    Eagle eagle = new Eagle("Coco-4-" + i);
                    Hunter hunter = new Hunter("Coco-2-" + i);

                    blackboard.placeOnBlackboard(eagle);
                    blackboard.placeOnBlackboard(mango);
                    blackboard.placeOnBlackboard(monkey);
                    blackboard.placeOnBlackboard(hunter);
                }
            }
        });

        Thread thread4 = new Thread(new Runnable() {
            public void run() {
                synchronized (blackboard) {
                    try {
                        blackboard.wait();
                    } catch (InterruptedException e) {
                    }
                }

                for (int i = 0; i < 100; i++) {
                    Monkey monkey = new Monkey("Coco-2-" + i);
                    Mango mango = new Mango("Coco-3-" + i);
                    Eagle eagle = new Eagle("Coco-1-" + i);
                    Hunter hunter = new Hunter("Coco-4-" + i);

                    blackboard.placeOnBlackboard(eagle);
                    blackboard.placeOnBlackboard(mango);
                    blackboard.placeOnBlackboard(monkey);
                    blackboard.placeOnBlackboard(hunter);
                }
            }
        });

        Thread thread5 = new Thread(new Runnable() {
            public void run() {
                synchronized (blackboard) {
                    try {
                        blackboard.wait();
                    } catch (InterruptedException e) {
                    }
                }

                for (int i = 0; i < 100; i++) {
                    Monkey monkey = new Monkey("Coco-5-" + i);
                    Mango mango = new Mango("Coco-4-" + i);
                    Eagle eagle = new Eagle("Coco-2-" + i);
                    Hunter hunter = new Hunter("Coco-1-" + i);

                    blackboard.placeOnBlackboard(eagle);
                    blackboard.placeOnBlackboard(mango);
                    blackboard.placeOnBlackboard(monkey);
                    blackboard.placeOnBlackboard(hunter);
                }
            }
        });

        thread1.start();
        thread2.start();

        thread3.start();
        thread4.start();
        thread5.start();

        try {
            Thread.currentThread().sleep(1000);
        } catch (Throwable t) {
        }

        synchronized (blackboard) {
            blackboard.notifyAll();
        }

        Object object = new Object();

        synchronized (object) {
            try {
                object.wait();
            } catch (InterruptedException e) {
            }
        }
    } finally {
    }
}

From source file:lince.LinceApp.java

/**
 * @param args the command line arguments
 *//*from  ww w .  j a v  a  2 s . c o m*/
public static void main(final String[] args) {
    String vlcPath = StringUtils.EMPTY;
    try {
        if (RuntimeUtil.isWindows()) {
            vlcPath = WindowsRuntimeUtil.getVlcInstallDir();
            /*if (StringUtils.isEmpty(vlcPath)){
                vlcPath= "C:\\Program Files (x86)\\VideoLAN";
            }*/
            System.setProperty("jna.library.path", vlcPath);
            setI18n();
        }
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                LinceFrame.getInstance();
            }
        });
    } catch (Exception e) {
        logger.log(Level.SEVERE, "Error inicializando main. vlcPath@" + vlcPath, e);
    }
}

From source file:MailTest.java

public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            JFrame frame = new MailTestFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);//from w  w w.  j  a va 2s  .  co m
        }
    });
}

From source file:gtu._work.ui.LogAppendStartEndUI.java

/**
* Auto-generated main method to display this JFrame
*//*from  w w  w. ja  v  a 2s . c  o  m*/
public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            LogAppendStartEndUI inst = new LogAppendStartEndUI();
            inst.setLocationRelativeTo(null);
            gtu.swing.util.JFrameUtil.setVisible(true, inst);
        }
    });
}

From source file:com.awesomecoding.minetestlauncher.Main.java

public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                Main window = new Main();
                window.frmMinetestLauncherV.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();/*w w w.  j  a  va 2  s . co  m*/
            }
        }
    });
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    URL urlFG = new URL("http://www.java2s.com/style/download.png");
    URL urlBG = new URL("http://www.java2s.com/style/download.png");
    final BufferedImage biFG = ImageIO.read(urlFG);
    final BufferedImage biBG = ImageIO.read(urlBG);
    SwingUtilities.invokeLater(new Runnable() {
        @Override//  w w w .j  a va  2  s . c o  m
        public void run() {
            draw(biBG, biFG);
        }
    });
}

From source file:MessageDigestTest.java

public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            JFrame frame = new MessageDigestFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);//from  w w  w  .j a v a2  s . c  om
        }
    });
}

From source file:TableRowColumnTest.java

public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            JFrame frame = new PlanetTableFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);/*w  ww. ja v a 2 s  .c om*/
        }
    });
}

From source file:TapTapTap.java

public static void main(String[] args) {
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            new TapTapTap().createUI();
        }/*from  www  .  jav  a  2 s  .c  om*/
    });
}