List of usage examples for java.lang InterruptedException printStackTrace
public void printStackTrace()
From source file:TQProducer.java
@Override public void run() { while (true) { try {/*from ww w .j a va 2 s .c o m*/ Thread.sleep(4000); int nextNum = this.sequence.incrementAndGet(); if (nextNum % 2 == 0) { System.out.format("%s: Enqueuing: %d%n", name, nextNum); tQueue.put(nextNum); // Enqueue } else { System.out.format("%s: Handing off: %d%n", name, nextNum); System.out.format("%s: has a waiting consumer: %b%n", name, tQueue.hasWaitingConsumer()); tQueue.transfer(nextNum); // A hand off } } catch (InterruptedException e) { e.printStackTrace(); } } }
From source file:Test.java
@Override public void run() { String itemName = ""; int itemId = 0; try {//from ww w .j a v a 2s . co m for (int x = 1; x < 8; x++) { itemName = "Item" + x; itemId = x; Test.linkTransQ.offer(new Item(itemName, itemId)); System.out.println("New Item Added:" + itemName + " " + itemId); Thread.currentThread().sleep(250); if (Test.linkTransQ.hasWaitingConsumer() == true) { System.out.println("Hurry up!"); } } } catch (InterruptedException ex) { ex.printStackTrace(); } }
From source file:com.ms.commons.file.service.ImageUtil.java
public static String rotateImage(String originalImagePath, Double rotation) { // FIXME?Java? // JavaRuntime? // convert 1372771154717.jpg -virtual-pixel none +distort SRT '20' rotate_normal2.png String destImage = TEMP_IMAGE_PATH + System.currentTimeMillis() + ".png"; try {//from w w w .ja va2s .c om String command = null; command = "convert " + originalImagePath + " -virtual-pixel none +distort SRT '" + rotation + "' " + destImage; Process process = Runtime.getRuntime().exec(command); process.waitFor(); int exitValue = process.exitValue(); return exitValue == 0 ? destImage : StringUtils.EMPTY; } catch (IOException e1) { e1.printStackTrace(); return StringUtils.EMPTY; } catch (InterruptedException e) { e.printStackTrace(); return StringUtils.EMPTY; } // ConvertCmd convert = new ConvertCmd(); // IMOperation op = new IMOperation(); // op.addImage(originalImagePath); // op.addRawArgs(" -virtual-pixel none +distort SRT '" + rotation + "' "); // op.addImage(destImage); // try { // convert.run(op); // return destImage; // } catch (Exception e) { // e.printStackTrace(); // return StringUtils.EMPTY; // } }
From source file:Main.java
private void shakeButton() { final Point point = button.getLocation(); final int delay = 75; Runnable r = new Runnable() { @Override//from w w w . j a va2 s . co m public void run() { for (int i = 0; i < 30; i++) { try { moveButton(new Point(point.x + 5, point.y)); Thread.sleep(delay); moveButton(point); Thread.sleep(delay); moveButton(new Point(point.x - 5, point.y)); Thread.sleep(delay); moveButton(point); Thread.sleep(delay); } catch (InterruptedException ex) { ex.printStackTrace(); } } } }; Thread t = new Thread(r); t.start(); }
From source file:com.company.project.service.TaskExample.java
@Override public void run() { System.out.println("Before :: " + name + " is running. Current time is :: " + new Date()); try {/* w w w . j a v a 2 s. c o m*/ Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("After :: " + name + " is running. Current time is :: " + new Date()); }
From source file:com.glaf.base.test.TestJob.java
public void runJob(JobExecutionContext context) throws JobExecutionException { String jobName = context.getJobDetail().getKey().getName(); logger.info("Executing job: " + jobName + " executing at " + DateUtils.getDateTime(new Date())); java.util.Random r = new java.util.Random(); try {//from w ww .ja v a2 s .c om Thread.sleep(r.nextInt(300000)); } catch (InterruptedException e) { e.printStackTrace(); } if (r.nextInt(3) % 3 == 0) { throw new RuntimeException("Not Support!"); } }
From source file:edu.illinois.cs.cogcomp.saulexamples.twitter.tweet.ClassifierMessageHandler.java
public void run() { while (!client.isDone()) { try {/*from w w w.j a v a 2 s . com*/ String msg = msgQueue.take(); Utils.printInfo(new JSONObject(msg)); String text = Utils.getCleanText(new JSONObject(msg)); // Need to convert the text to a Tweet datastructure for the classifier to work String decision = classifier.discreteValue(new Tweet(text)); System.out.println("\t***Sentiment classification: " + decision); } catch (InterruptedException e) { e.printStackTrace(); } } client.stop(); }
From source file:Main.java
private void shakeButton() { final Point point = button.getLocation(); final Insets margin = button.getMargin(); final int delay = 75; Runnable r = new Runnable() { @Override/*from w w w .j av a 2 s .c om*/ public void run() { for (int i = 0; i < 30; i++) { try { setButtonMargin(new Insets(margin.top, margin.left + 3, margin.bottom, margin.right - 2)); Thread.sleep(delay); setButtonMargin(margin); Thread.sleep(delay); setButtonMargin(new Insets(margin.top, margin.left - 2, margin.bottom, margin.right + 3)); Thread.sleep(delay); setButtonMargin(margin); Thread.sleep(delay); } catch (InterruptedException ex) { ex.printStackTrace(); } } } }; Thread t = new Thread(r); t.start(); }
From source file:org.lottery.common.message.ProducerTest.java
@Test public void testSend() { final ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(CONFIG); ctx.start();// w w w .j a v a 2 s. com final MessageChannel channel = ctx.getBean("common-message.producer", MessageChannel.class); channel.send(MessageBuilder.withPayload("from messageChannel" + System.currentTimeMillis()) .setHeader("messageKey", "key").setHeader("topic", "test").build()); MessageProducer messageProducer = ctx.getBean(MessageProducer.class); messageProducer.send("test", "from messageProducer" + System.currentTimeMillis()); try { Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); } ctx.close(); }
From source file:MainClass.java
public void run() { int sum = 0;//from ww w . jav a 2 s .c o m for (int i = 1; i <= 10; i++) { try { Thread.sleep(1000); sum += buffer.get(); System.out.printf("\t\t\t%2d\n", sum); } catch (InterruptedException exception) { exception.printStackTrace(); } } System.out.printf("\n%s %d.\n%s\n", "Consumer read values totaling", sum, "Terminating Consumer."); }