Example usage for java.lang InterruptedException printStackTrace

List of usage examples for java.lang InterruptedException printStackTrace

Introduction

In this page you can find the example usage for java.lang InterruptedException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:ThreadDemo.java

public void run() {
    try {/*from   w  w w.ja v  a 2s. co m*/
        Thread.sleep(1000);
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    System.out.println(Thread.currentThread().getName() + "yielding control...");
    Thread.yield();

    System.out.println(Thread.currentThread().getName() + " has finished executing.");
}

From source file:com.ling.spring.event.TestEvent.java

@Test
public void testEvent() {
    applicationContext.publishEvent(new ContentEvent("?"));
    try {//from w w w .j  a  v  a  2s  .c o m
        Thread.currentThread().sleep(10000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:com.github.liyp.rabbitmq.demo.QueueOneListener.java

@Override
public void onMessage(Message message) {
    try {//w  w w  . j ava 2  s. com
        Thread.sleep(1000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    System.out.println(
            "ONE# Listener data :" + message.toString() + "thread : " + Thread.currentThread().toString());
}

From source file:Test.java

private void generateOrder(Item item) {
    System.out.println(item.getDescription());
    System.out.println(item.getItemId());
    try {//from   ww  w . jav  a2 s  . co  m
        Thread.currentThread().sleep(1000);
    } catch (InterruptedException ex) {
        ex.printStackTrace();
    }
}

From source file:Producer.java

synchronized void add(int i) {
    while (count == SIZE) {
        try {//from w  w w  .j a  v a 2 s.  c  o m
            wait();
        } catch (InterruptedException ie) {
            ie.printStackTrace();
            System.exit(0);
        }
    }
    queue.addElement(new Integer(i));
    ++count;
    notifyAll();
}

From source file:Consumer.java

public synchronized void produce(int newData) {
    while (!this.empty) {
        try {//from   w ww  .  ja v  a2s .c o m
            this.wait();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    this.data = newData;
    this.empty = false;
    this.notify();
    System.out.println("Produced:" + newData);
}

From source file:Consumer.java

public synchronized int consume() {
    while (this.empty) {
        try {/*from  www .  ja  v  a2 s  . co  m*/
            this.wait();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    this.empty = true;
    this.notify();
    System.out.println("Consumed:" + data);
    return data;
}

From source file:com.ling.spring.task.FixedRateTask.java

/**
 * fixedRate ?//  w ww  . j  a  v  a  2s  .  c o  m
 * fixedDelay ??
 */
@Async
@Scheduled(fixedRate = 5000)
public void runTask() {
    System.out.println("fixedRate run..." + format.format(new Date()));
    try {
        Thread.currentThread().sleep(5000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    String s = null;
    System.out.println(s.toString());
}

From source file:Producer.java

synchronized int remove() {
    while (count == 0) {
        try {/*from   w w  w.  j  a  v a  2s .  c o  m*/
            wait();
        } catch (InterruptedException ie) {
            ie.printStackTrace();
            System.exit(0);
        }
    }
    Integer iobj = (Integer) queue.firstElement();
    queue.removeElement(iobj);
    --count;
    notifyAll();
    return iobj.intValue();
}

From source file:edu.illinois.cs.cogcomp.saulexamples.twitter.tweet.SimpleMessageHandler.java

public void run() {
    while (!client.isDone()) {
        try {/* w w  w . j  a v  a  2  s  .  co  m*/
            String msg = msgQueue.take();
            Utils.printInfo(new JSONObject(msg));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    client.stop();
}