List of usage examples for java.lang Runnable Runnable
Runnable
From source file:InternalFrameTest.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { JFrame frame = new DesktopFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);/*from w w w .ja v a2s . c om*/ } }); }
From source file:ImageTransferTest.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { JFrame frame = new ImageTransferFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);/*from ww w.j a v a 2 s. c o m*/ } }); }
From source file:gtu.xml.work.CacDBUI4Janna.java
/** * Auto-generated main method to display this JFrame *///from ww w. j a v a 2 s . co m public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { CacDBUI4Janna inst = new CacDBUI4Janna(); inst.setLocationRelativeTo(null); gtu.swing.util.JFrameUtil.setVisible(true, inst); } }); }
From source file:PostTest.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { JFrame frame = new PostTestFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);// www. java 2 s . c om } }); }
From source file:org.eclipse.swt.snippets.Snippet174.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("OpenGL in SWT"); shell.setLayout(new FillLayout()); GLData data = new GLData(); data.doubleBuffer = true;//from w w w. j ava 2s. co m final GLCanvas canvas = new GLCanvas(shell, SWT.NO_BACKGROUND, data); canvas.addControlListener(new ControlAdapter() { public void controlResized(ControlEvent e) { resize(canvas); } }); init(canvas); new Runnable() { public void run() { if (canvas.isDisposed()) return; render(); canvas.swapBuffers(); canvas.getDisplay().timerExec(50, this); } }.run(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:DesktopAppTest.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { JFrame frame = new DesktopAppFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);//from ww w .j ava 2s.c o m } }); }
From source file:DOMTreeTest.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { JFrame frame = new DOMTreeFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);/*from ww w . j ava 2 s .co m*/ } }); }
From source file:ThreadDemo.java
/** * This main method creates and starts two threads in addition to the initial * thread that the interpreter creates to invoke the main() method. *//*from ww w . j ava 2 s.c om*/ public static void main(String[] args) { // Create the first thread: an instance of this class. Its body is // the run() method above ThreadDemo thread1 = new ThreadDemo(); // Create the second thread by passing a Runnable object to the // Thread() construtor. The body of this thread is the run() method // of the anonymous Runnable object below. Thread thread2 = new Thread(new Runnable() { public void run() { for (int i = 0; i < 5; i++) compute(); } }); // Set the priorities of these two threads, if any are specified if (args.length >= 1) thread1.setPriority(Integer.parseInt(args[0])); if (args.length >= 2) thread2.setPriority(Integer.parseInt(args[1])); // Start the two threads running thread1.start(); thread2.start(); // This main() method is run by the initial thread created by the // Java interpreter. Now that thread does some stuff, too. for (int i = 0; i < 5; i++) compute(); // We could wait for the threads to stop running with these lines // But they aren't necessary here, so we don't bother. // try { // thread1.join(); // thread2.join(); // } catch (InterruptedException e) {} // The Java VM exits only when the main() method returns, and when all // threads stop running (except for daemon threads--see setDaemon()). }
From source file:com.taobao.tddl.common.DynamicLogTest.java
public static void main(String[] args) throws InterruptedException { MockServer.setUpMockServer();// w ww . ja v a 2 s . c om 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:BusyCursorDisplay.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new GridLayout()); final Text text = new Text(shell, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); text.setLayoutData(new GridData(GridData.FILL_BOTH)); final int[] nextId = new int[1]; Button b = new Button(shell, SWT.PUSH); b.setText("invoke long running job"); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Runnable longJob = new Runnable() { boolean done = false; int id; public void run() { Thread thread = new Thread(new Runnable() { public void run() { id = nextId[0]++; display.syncExec(new Runnable() { public void run() { if (text.isDisposed()) return; text.append("\nStart long running task " + id); }// www . j a v a2s . co m }); for (int i = 0; i < 100000; i++) { if (display.isDisposed()) return; System.out.println("do task that takes a long time in a separate thread " + id); } if (display.isDisposed()) return; display.syncExec(new Runnable() { public void run() { if (text.isDisposed()) return; text.append("\nCompleted long running task " + id); } }); done = true; display.wake(); } }); thread.start(); while (!done && !shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } }; BusyIndicator.showWhile(display, longJob); } }); shell.setSize(250, 150); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }