List of usage examples for java.lang InterruptedException printStackTrace
public void printStackTrace()
From source file:net.vnt.ussdapp.USSDApp.java
public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "/context.xml" }); ContextProperties properties = (ContextProperties) Context.getInstance().getBean("ContextProperties"); try {/* w w w . ja v a 2s .c o m*/ if (USSD.initialize() == 0) { System.out.println("Error initializing"); return; } if (USSD.connect(properties.getProperty("ip.ussdgw"), properties.getInt("port.ussdgw")) == 0) { System.out.println("Error connecting"); return; } while (true) { Thread.sleep(1000); } } catch (InterruptedException ex) { ex.printStackTrace(); } }
From source file:ScheduledTask.java
public static void main(String[] args) { // Get an executor with 3 threads ScheduledExecutorService sexec = Executors.newScheduledThreadPool(3); ScheduledTask task1 = new ScheduledTask(1); ScheduledTask task2 = new ScheduledTask(2); // Task #1 will run after 2 seconds sexec.schedule(task1, 2, TimeUnit.SECONDS); // Task #2 runs after 5 seconds delay and keep running every 10 seconds sexec.scheduleAtFixedRate(task2, 5, 10, TimeUnit.SECONDS); try {/* w ww .j av a 2s . c o m*/ TimeUnit.SECONDS.sleep(60); } catch (InterruptedException e) { e.printStackTrace(); } sexec.shutdown(); }
From source file:Main.java
public static void main(String... s) { cdl = new CountDownLatch(1); Thread a = new Thread(() -> { System.out.println("started a"); try {/* ww w .j av a2s. com*/ Thread.sleep(4000); } catch (InterruptedException e) { e.printStackTrace(); } cdl.countDown(); System.out.println("stoped a"); }); Thread b = new Thread(() -> { System.out.println("started b"); System.out.println("wait a"); try { cdl.await(); } catch (Exception e) { e.printStackTrace(); } System.out.println("stoped b"); }); b.start(); a.start(); }
From source file:mjg.spring.Demo.java
public static void main(String[] args) { ApplicationContext ctx = new FileSystemXmlApplicationContext("resources/applicationContext.xml"); Evaluator e = null;/* w w w . j a v a 2 s.co m*/ boolean ok; for (int i = 0; i < 10; i++) { e = (Evaluator) ctx.getBean("groovyEvaluator"); ok = e.approve(null); System.out.println(ok ? "approved" : "denied"); try { Thread.sleep(1000); } catch (InterruptedException ie) { ie.printStackTrace(); } } ((FileSystemXmlApplicationContext) ctx).close(); }
From source file:MainClass.java
public static void main(String[] args) { Thread first = new TryThread("A ", "a ", 200L); Thread second = new TryThread("B ", "b ", 300L); Thread third = new TryThread("C ", "c ", 500L); first.start();/*from www . ja va 2 s . c om*/ second.start(); third.start(); try { first.join(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:FlagComm.java
public static void main(String args[]) { FlagSend s = new FlagSend(); FlagRec r = new FlagRec(s); Thread st = new Thread(s); Thread rt = new Thread(r); rt.setDaemon(true);/* w w w. ja v a 2 s. c o m*/ st.start(); rt.start(); try { while (s.isValid) { Thread.sleep(100); } } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:Producer.java
public static void main(String[] args) { BlockingDeque<Integer> deque = new LinkedBlockingDeque<Integer>(5); Runnable producer = new Producer("Producer", deque); Runnable consumer = new Consumer("Consumer", deque); new Thread(producer).start(); try {//from ww w. ja va 2 s . com Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } new Thread(consumer).start(); }
From source file:SyncBlock.java
public static void main(String[] args) { try {// w w w .ja v a 2 s .co m SyncBlock sb = new SyncBlock(); Thread t1 = launch(sb, "T1"); Thread.sleep(500); Thread t2 = launch(sb, "T2"); Thread t3 = launch(sb, "T3"); Thread.sleep(1000); print("about to interrupt T2"); t2.interrupt(); print("just interrupted T2"); } catch (InterruptedException x) { x.printStackTrace(); } }
From source file:Test.java
public static void main(String[] args) { final AtomicLong orderIdGenerator = new AtomicLong(0); final List<Item> orders = Collections.synchronizedList(new ArrayList<Item>()); for (int i = 0; i < 10; i++) { Thread orderCreationThread = new Thread(new Runnable() { public void run() { for (int i = 0; i < 10; i++) { long orderId = orderIdGenerator.incrementAndGet(); Item order = new Item(Thread.currentThread().getName(), orderId); orders.add(order);//from w w w.j av a 2s . co m } } }); orderCreationThread.setName("Order Creation Thread " + i); orderCreationThread.start(); } try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } Set<Long> orderIds = new HashSet<Long>(); for (Item order : orders) { orderIds.add(order.getID()); System.out.println("Order id:" + order.getID()); } }
From source file:com.villemos.ispace.Starter.java
public static void main(String[] args) { System.out.println("Starting iSpace."); try {//from www . j av a 2 s . co m /** Read the configuration file as the first argument. If not set, then we try the default name. */ String assemblyFile = System.getProperty("ispace.assembly") == null ? "assembly.xml" : System.getProperty("ispace.assembly"); System.out.println("Using assembly file " + assemblyFile); new FileSystemXmlApplicationContext(assemblyFile); while (true) { try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } }