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:WaitComm.java

public static void main(String args[]) {
    WFlagSend s = new WFlagSend();
    WFlagRec r = new WFlagRec(s);
    Thread st = new Thread(s);
    Thread rt = new Thread(r);
    rt.setDaemon(true);//www .j  a va  2  s  .  co  m
    st.start();
    rt.start();
    try {
        st.join();
        while (s.isValid) {
            Thread.sleep(100);
        }
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {
    JFrame parentFrame = new JFrame();
    parentFrame.setSize(500, 150);/* w  w w.  jav a  2s  . c  o  m*/
    JLabel jl = new JLabel();
    jl.setText("Count : 0");

    parentFrame.add(BorderLayout.CENTER, jl);
    parentFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    parentFrame.setVisible(true);

    final JDialog dlg = new JDialog(parentFrame, "Progress Dialog", true);
    JProgressBar dpb = new JProgressBar(0, 500);
    dlg.add(BorderLayout.CENTER, dpb);
    dlg.add(BorderLayout.NORTH, new JLabel("Progress..."));
    dlg.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    dlg.setSize(300, 75);
    dlg.setLocationRelativeTo(parentFrame);

    Thread t = new Thread(new Runnable() {
        public void run() {
            dlg.setVisible(true);
        }
    });
    t.start();
    for (int i = 0; i <= 500; i++) {
        jl.setText("Count : " + i);
        dpb.setValue(i);
        if (dpb.getValue() == 500) {
            dlg.setVisible(false);
            System.exit(0);

        }
        try {
            Thread.sleep(25);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    dlg.setVisible(true);
}

From source file:com.twitlinks.Main.java

/**
 * @param args/*from  w w  w .j  a v a  2  s .com*/
 * @throws ParseException 
 * @throws org.apache.lucene.queryParser.ParseException 
 * @throws IOException 
 * @throws InterruptedException 
 */
public static void main(String[] args)
        throws ParseException, IOException, org.apache.lucene.queryParser.ParseException, InterruptedException {
    Log log = LogFactory.getLog(Main.class);

    Parser parser = new Parser(true, "dataset_2m");
    parser.start();

    Indexer indexer = new Indexer();
    indexer.start();
    while (true) {
        try {
            Thread.sleep(2000);
            log.info(parser.getLinesRead() + ":" + indexer.docCount + ":" + Buffer.documentQueue.size());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        if (!parser.isAlive() && Buffer.documentQueue.size() == 0) {
            log.info(parser.getLinesRead() + ":" + indexer.docCount + ":" + Buffer.documentQueue.size());
            indexer.stopIndexing();
            break;
        }
    }

    //Test the simple search, current text:fantastic
    SimpleSearcher searcher = new SimpleSearcher();
    searcher.searcher();
}

From source file:EarlyReturn.java

public static void main(String[] args) {
    try {// w w  w . j  a va 2 s.c  om
        final EarlyReturn er = new EarlyReturn(0);

        Runnable r = new Runnable() {
            public void run() {
                try {
                    Thread.sleep(1500);
                    er.setValue(2);
                    Thread.sleep(500);
                    er.setValue(3);
                    Thread.sleep(500);
                    er.setValue(4);
                } catch (Exception x) {
                    x.printStackTrace();
                }
            }
        };

        Thread t = new Thread(r);
        t.start();

        System.out.println("waitUntilAtLeast(5, 3000)");
        long startTime = System.currentTimeMillis();
        boolean retVal = er.waitUntilAtLeast(5, 3000);
        long elapsedTime = System.currentTimeMillis() - startTime;

        System.out.println(elapsedTime + " ms, retVal=" + retVal);
    } catch (InterruptedException ix) {
        ix.printStackTrace();
    }
}

From source file:TQProducer.java

public static void main(String[] args) {
    final TransferQueue<Integer> tQueue = new LinkedTransferQueue<>();
    final AtomicInteger sequence = new AtomicInteger();

    for (int i = 0; i < 5; i++) {
        try {/*from w w  w . ja v a  2s. co  m*/
            tQueue.put(sequence.incrementAndGet());
            System.out.println("Initial queue: " + tQueue);

            new TQProducer("Producer-1", tQueue, sequence).start();
            new TQConsumer("Consumer-1", tQueue).start();

        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}

From source file:com.sm.test.TestClient.java

public static void main(String[] args) {
    ccf = ClusterClientFactory.connect(HOST_CONNECT_URL, STORENAME);
    client = ccf.getDefaultStore();/*  ww w.  j av a2 s.com*/
    while (true) {
        try {
            long time = System.currentTimeMillis() / 1000;
            ByteArrayConverter converter = new ByteArrayConverter();
            Key<ByteArray> key = Key.createKey(new ByteArray("1.abcdef".getBytes()));
            Bar bar = new Bar();
            client.put(key, new ByteArray("FooBar".getBytes()));
            Value<ByteArray> value = client.get(key);
            System.out.println("" + new String(value.getData().get()));
            try {
                Thread.sleep(3000L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
        if (false)
            break;
    }
    client.close();
    ccf.close();
}

From source file:com.mmj.app.common.util.PushSMSUtils.java

public static void main(String[] args) {
    for (int i = 1; i < 2; i++) {
        PushSMSUtils pushUtils = new PushSMSUtils();
        System.out.println(/*from  w  ww . j  a va2 s.  c o  m*/
                "?,!!!???,! " + i + ",Test Start!");

        pushUtils.sendPushMsg("??3478??", "18912386146");

        System.out.println(
                "?,!!!???,! " + i + ",Test End!");

        System.out.println("Now,start sleep!");
        try {
            Thread.sleep(1000 * 180);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("Now,sleep end!");
    }
}

From source file:ProducerComsumer.java

public static void main(String[] args) {
    final ProducerComsumer ch = new ProducerComsumer();

    Runnable runA = new Runnable() {
        public void run() {
            try {
                String str;//w  w w. j  a v a  2s  .  c o m
                Thread.sleep(500);

                str = "multithreaded";
                ch.putIn(str);
                str = "programming";
                ch.putIn(str);

                str = "with Java";
                ch.putIn(str);
            } catch (InterruptedException x) {
                x.printStackTrace();
            }
        }
    };

    Runnable runB = new Runnable() {
        public void run() {
            try {
                Object obj;

                obj = ch.takeOut();
                System.out.println("in run() - just took out: '" + obj + "'");

                Thread.sleep(500);

                obj = ch.takeOut();
                System.out.println("in run() - just took out: '" + obj + "'");

                obj = ch.takeOut();
                System.out.println("in run() - just took out: '" + obj + "'");
            } catch (InterruptedException x) {
                x.printStackTrace();
            }
        }
    };

    Thread threadA = new Thread(runA, "threadA");
    threadA.start();

    Thread threadB = new Thread(runB, "threadB");
    threadB.start();
}

From source file:SimpleObjectFIFO.java

public static void main(String[] args) {
    try {//from  w  ww. j  a  v a  2 s .c  om
        SimpleObjectFIFO fifo = new SimpleObjectFIFO(5);
        fifo.printState();

        fifo.add("S01");
        fifo.printState();

        fifo.add("S02");
        fifo.printState();

        fifo.add("S03");
        fifo.printState();

        Object obj = fifo.remove();
        System.out.println("just removed obj=" + obj);
        fifo.printState();

        fifo.add("S04");
        fifo.printState();

        fifo.add("S05");
        fifo.printState();

        fifo.add("S06");
        fifo.printState();
    } catch (InterruptedException x) {
        x.printStackTrace();
    }
}

From source file:de.avanux.livetracker.sender.LocationSender.java

public static void main(String[] args) {
    try {//from  w  ww. ja v  a2s.  com
        LocationSender sender = new LocationSender();
        Configuration configuration = sender.requestConfiguration(args[0]);
        float lon = 8.9842f;
        for (int i = 0; i < 10; i++) {
            sender.sendPositionData(configuration, 50.2911f, lon);
            //                lon += 0.002;
            lon += 0.005;
            log.debug("Waiting for " + configuration.getMinTimeInterval() + " seconds.");
            Thread.sleep(configuration.getMinTimeInterval() * 1000);
        }
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}