List of usage examples for java.lang Runnable Runnable
Runnable
From source file:RobotTest.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { // make frame with a button panel ButtonFrame frame = new ButtonFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);//from w w w .ja v a 2s . c o m // attach a robot to the screen device GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice screen = environment.getDefaultScreenDevice(); try { Robot robot = new Robot(screen); runTest(robot); } catch (AWTException e) { e.printStackTrace(); } } }); }
From source file:ZipTest.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { ZipTestFrame frame = new ZipTestFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);// w ww. j a v a 2 s. c o m } }); }
From source file:TextTransferTest.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { JFrame frame = new TextTransferFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);//from w ww. ja v a2s . co m } }); }
From source file:com.sourcethought.simpledaemon.EchoTask.java
public static void main(String[] args) throws Exception { // setup command line options Options options = new Options(); options.addOption("h", "help", false, "print this help screen"); // read command line options CommandLineParser parser = new PosixParser(); try {/* w ww . j a va2s . co m*/ CommandLine cmdline = parser.parse(options, args); if (cmdline.hasOption("help") || cmdline.hasOption("h")) { System.out.println("SimpleDaemon Version " + Main.version); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp( "java -cp lib/*:target/SimpleDaemon-1.0-SNAPSHOT.jar com.sourcethought.simpledaemon.Main", options); return; } final SimpleDaemon daemon = new SimpleDaemon(); daemon.start(); Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { if (daemon.isRunning()) { try { System.out.println("Shutting down daemon..."); daemon.stop(); } catch (Exception ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } } } })); } catch (ParseException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.nomt.agent.main.NomtAgentMain.java
public static void main(String[] args) { ThreadUtil.startNewTask(new Runnable() { @Override//ww w. j a v a 2s .co m public void run() { logger.debug("NomtAgentMain start."); final String SPRING_CONTEXT_XML = "agent-spring-all.xml"; logger.debug("Spring context XML file is {}.", SPRING_CONTEXT_XML); // schedulerFactoryBean spring ApplicationContext ctx = new ClassPathXmlApplicationContext(SPRING_CONTEXT_XML); } }); }
From source file:com.github.liyp.test.TestMain.java
@SuppressWarnings("unchecked") public static void main(String[] args) { // add a shutdown hook to stop the server Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override//from w w w . j ava 2 s . com public void run() { System.out.println("########### shoutdown begin...."); try { Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("########### shoutdown end...."); } })); System.out.println(args.length); Iterator<String> iterator1 = IteratorUtils .arrayIterator(new String[] { "one", "two", "three", "11", "22", "AB" }); Iterator<String> iterator2 = IteratorUtils.arrayIterator(new String[] { "a", "b", "c", "33", "ab", "aB" }); Iterator<String> chainedIter = IteratorUtils.chainedIterator(iterator1, iterator2); System.out.println("=================="); Iterator<String> iter = IteratorUtils.filteredIterator(chainedIter, new Predicate() { @Override public boolean evaluate(Object arg0) { System.out.println("xx:" + arg0.toString()); String str = (String) arg0; return str.matches("([a-z]|[A-Z]){2}"); } }); while (iter.hasNext()) { System.out.println(iter.next()); } System.out.println("==================="); System.out.println("asas".matches("[a-z]{4}")); System.out.println("Y".equals(null)); System.out.println(String.format("%02d", 1000L)); System.out.println(ArrayUtils.toString(splitAndTrim(" 11, 21,12 ,", ","))); System.out.println(new ArrayList<String>().toString()); JSONObject json = new JSONObject("{\"keynull\":null}"); json.put("bool", false); json.put("keya", "as"); json.put("key2", 2212222222222222222L); System.out.println(json); System.out.println(json.get("keynull").equals(null)); String a = String.format("{\"id\":%d,\"method\":\"testCrossSync\"," + "\"circle\":%d},\"isEnd\":true", 1, 1); System.out.println(a.getBytes().length); System.out.println(new String[] { "a", "b" }); System.out.println(new JSONArray("[\"aa\",\"\"]")); String data = String.format("%9d %s", 1, RandomStringUtils.randomAlphanumeric(10)); System.out.println(data.getBytes().length); System.out.println(ArrayUtils.toString("1|2| 3| 333||| 3".split("\\|"))); JSONObject j1 = new JSONObject("{\"a\":\"11111\"}"); JSONObject j2 = new JSONObject(j1.toString()); j2.put("b", "22222"); System.out.println(j1 + " | " + j2); System.out.println("======================"); String regex = "\\d+(\\-\\d+){2} \\d+(:\\d+){2}"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher("2015-12-28 15:46:14 _NC250_MD:motion de\n"); String eventDate = matcher.find() ? matcher.group() : ""; System.out.println(eventDate); }
From source file:ThreadTask.java
public static void main(String args[]) { final String message[] = { "Java", "Source", "and", "Support" }; ThreadPool pool = new ThreadPool(message.length / 2); for (int i = 0, n = message.length; i < n; i++) { final int innerI = i; Runnable runner = new Runnable() { public void run() { for (int j = 0; j < 25; j++) { System.out.println("j: " + j + ": " + message[innerI]); }//from ww w .jav a2 s. c o m } }; pool.run(runner); } }
From source file:gtu._work.ui.QuartzCronTestUI.java
public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { QuartzCronTestUI inst = new QuartzCronTestUI(); inst.setLocationRelativeTo(null); gtu.swing.util.JFrameUtil.setVisible(true, inst); }/*from w w w . j a v a 2s.com*/ }); }
From source file:SpinnerTest.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { SpinnerFrame frame = new SpinnerFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);//from www . j a va 2 s.c o m } }); }
From source file:gtu._work.ui.ObnfCheckPDFErrorUI.java
/** * Auto-generated main method to display this JFrame *//*from ww w.j a v a2 s . com*/ public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { ObnfCheckPDFErrorUI inst = new ObnfCheckPDFErrorUI(); inst.setLocationRelativeTo(null); gtu.swing.util.JFrameUtil.setVisible(true, inst); } }); }