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:Main.java

public static void main(String[] args) {
    // Get the scheduler
    ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();

    // Get a handle, starting now, with a 10 second delay
    final ScheduledFuture<?> timeHandle = scheduler.scheduleAtFixedRate(new TimePrinter(System.out), 0, 10,
            SECONDS);/*from   w  ww. java 2s .  co  m*/

    // Schedule the event, and run for 1 hour (60 * 60 seconds)
    scheduler.schedule(new Runnable() {
        public void run() {
            timeHandle.cancel(false);
        }
    }, 60 * 60, SECONDS);

    /**
     * On some platforms, you'll have to setup this infinite loop to see output
    while (true) { }
     */
}

From source file:DialogTest.java

public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            DialogFrame frame = new DialogFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);/*from  www  . ja  va 2 s  . c om*/
        }
    });
}

From source file:ToolBarTest.java

public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            ToolBarFrame frame = new ToolBarFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);/*from  w  w w  . ja v  a2s.c o  m*/
        }
    });
}

From source file:ConsoleWindowTest.java

public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            // this is the button test program from chapter 8
            ButtonFrame frame = new ButtonFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);//from  w w  w . ja  v a2s  .  com

            // initialize the console window--System.out will show here
            ConsoleWindow.init();
        }
    });
}

From source file:Snippet7.java

public static void main(String[] args) {
    final Display display = new Display();
    final Image image = new Image(display, 16, 16);
    GC gc = new GC(image);
    gc.setBackground(display.getSystemColor(SWT.COLOR_RED));
    gc.fillRectangle(image.getBounds());
    gc.dispose();//ww w. ja v a  2 s  .  co m
    final Shell shell = new Shell(display);
    shell.setText("Lazy Table");
    shell.setLayout(new FillLayout());
    final Table table = new Table(shell, SWT.BORDER | SWT.MULTI);
    table.setSize(200, 200);
    Thread thread = new Thread() {
        public void run() {
            for (int i = 0; i < 20000; i++) {
                if (table.isDisposed())
                    return;
                final int[] index = new int[] { i };
                display.syncExec(new Runnable() {
                    public void run() {
                        if (table.isDisposed())
                            return;
                        TableItem item = new TableItem(table, SWT.NONE);
                        item.setText("Table Item " + index[0]);
                        item.setImage(image);
                    }
                });
            }
        }
    };
    thread.start();
    shell.setSize(200, 200);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    image.dispose();
    display.dispose();
}

From source file:PropertiesTest.java

public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            PropertiesFrame frame = new PropertiesFrame();
            frame.setVisible(true);//from  w  ww .  j a v a 2  s .c  o m
        }
    });
}

From source file:aurelienribon.gdxsetupui.ui.Main.java

public static void main(String[] args) {
    parseArgs(args);//from  w w  w.  j av a 2s . co m

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (ClassNotFoundException ex) {
            } catch (InstantiationException ex) {
            } catch (IllegalAccessException ex) {
            } catch (UnsupportedLookAndFeelException ex) {
            }

            SwingStyle.init();
            ArStyle.init();

            JFrame frame = new JFrame("LibGDX Project Setup (gdx-setup-ui)");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setContentPane(new MainPanel());
            frame.setSize(1100, 600);
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    });
}

From source file:mase.MaseManagerTerminal.java

public static void main(String[] args) {
    File r = null, j = null;//from  www. j  a  v a2 s.  c  o m
    if (args.length > 0) {
        r = new File(args[0]);
    }
    if (args.length > 1) {
        j = new File(args[1]);
    }

    final MaseManager manager = new MaseManager();
    final MaseManagerTerminal terminal = new MaseManagerTerminal(manager);
    manager.setStatusListener(terminal);

    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
        @Override
        public void run() {
            terminal.message("Exiting gracefully");
            manager.cancelAll();
        }
    }));

    manager.startExecution();
    terminal.run(r, j);
}

From source file:ActionTest.java

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

From source file:SwingThreadTest.java

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