List of usage examples for java.lang Runnable Runnable
Runnable
From source file:TestSynchronized.java
public static void main(String[] args) throws Exception { final TestSynchronized tus = new TestSynchronized(); Runnable runA = new Runnable() { public void run() { tus.performATask(1);//from ww w . java 2 s .com } }; Thread ta = new Thread(runA, "threadA"); ta.start(); Thread.sleep(2000); Runnable runB = new Runnable() { public void run() { tus.performATask(2); } }; Thread tb = new Thread(runB, "threadB"); tb.start(); }
From source file:StaticSync.java
public static void main(String[] args) { try {//from w w w.ja va 2 s . c o m Runnable r = new Runnable() { public void run() { print("getNextSerialNum()=" + getNextSerialNum()); } }; Thread threadA = new Thread(r, "threadA"); threadA.start(); Thread.sleep(1500); Thread threadB = new Thread(r, "threadB"); threadB.start(); Thread.sleep(500); Thread threadC = new Thread(r, "threadC"); threadC.start(); Thread.sleep(2500); Thread threadD = new Thread(r, "threadD"); threadD.start(); } catch (InterruptedException x) { // ignore } }
From source file:edu.eci.arsw.exam.Main.java
public static void main(String a[]) { ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml"); final MainFrame mf = ac.getBean(MainFrame.class); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { mf.setVisible(true);/*w w w. jav a 2 s .co m*/ } }); }
From source file:Main.java
public static void main(String[] args) throws Exception { URL url = new URL("http://www.java2s.com/style/download.png"); final BufferedImage image = ImageIO.read(url); int x = 50;/*from ww w. j a v a2s . c o m*/ final Image crop = image.getSubimage(x, 0, image.getWidth() - x, image.getHeight()); Runnable r = new Runnable() { @Override public void run() { JPanel gui = new JPanel(); gui.add(new JLabel(new ImageIcon(image)), BorderLayout.LINE_START); gui.add(new JLabel("java2s.com")); gui.add(new JLabel(new ImageIcon(crop)), BorderLayout.LINE_END); JOptionPane.showMessageDialog(null, gui); } }; SwingUtilities.invokeLater(r); }
From source file:dev.dposadsky.java.swingteacherdesktop.main.Start.java
public static void main(String[] args) throws SQLException { SwingUtilities.invokeLater(new Runnable() { @Override//from w w w. ja v a 2 s .c o m public void run() { ApplicationContext context = new ClassPathXmlApplicationContext("context.xml"); MainFrameController mainFrameController = (MainFrameController) context .getBean("mainFrameController"); } }); }
From source file:StaticBlock.java
public static void main(String[] args) { Runnable runA = new Runnable() { public void run() { StaticBlock.staticA();//from ww w. j a v a 2 s . c om } }; Thread threadA = new Thread(runA, "A"); threadA.start(); try { Thread.sleep(200); } catch (InterruptedException x) { } Runnable runB = new Runnable() { public void run() { StaticBlock.staticB(); } }; Thread threadB = new Thread(runB, "B"); threadB.start(); }
From source file:TestUnsynchronized.java
public static void main(String[] args) throws Exception { final TestUnsynchronized tus = new TestUnsynchronized(); Runnable runA = new Runnable() { public void run() { tus.doAction(3);/*from w w w. ja v a2s . c om*/ } }; Thread ta = new Thread(runA, "threadA"); ta.start(); Thread.sleep(2000); Runnable runB = new Runnable() { public void run() { tus.doAction(7); } }; Thread tb = new Thread(runB, "threadB"); tb.start(); }
From source file:es.udc.fic.medregatas.MyApplication.java
public static void main(String[] args) throws Exception { ApplicationContext context = new ClassPathXmlApplicationContext("classpath:/spring-config.xml"); final MainAppjFrame mainAppjFrame = new MainAppjFrame(context); /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { mainAppjFrame.setLocationRelativeTo(null); mainAppjFrame.setVisible(true); }/* w w w. j a v a2s . co m*/ }); }
From source file:Main.java
public static void main(String[] args) throws Exception { Robot robot = new Robot(); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); BufferedImage image = robot.createScreenCapture(new Rectangle(d)); BufferedImage sub = image.getSubimage(0, 0, 400, 400); File f = new File("SubImage.png"); ImageIO.write(sub, "png", f); final ImageIcon im = new ImageIcon(f.toURI().toURL()); Runnable r = new Runnable() { @Override//from w w w. ja v a 2s .c o m public void run() { JOptionPane.showMessageDialog(null, new JLabel(im)); } }; SwingUtilities.invokeLater(r); }
From source file:com.milkdairy.admin.MilkDairyManagement.java
public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { Resource resource = new ClassPathResource("applicationContext.xml"); BeanFactory factory = new XmlBeanFactory(resource); JPanel milkDairyManagementJPanel = (MilkDairyManagementJPanel) factory .getBean("milkDairyManagementJPanel"); UIManager.put("swing.boldmetal", Boolean.FALSE); new LoginJFrame(milkDairyManagementJPanel, (LoggingService) factory.getBean("loggingService")) .setVisible(true);/*from w ww . ja v a 2s . c o m*/ } }); }