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:com.bukanir.android.utils.Utils.java

public static boolean isStorageVfat(Context context) {
    try {/*w  w w.java2s. c  om*/
        String cacheDir = context.getExternalCacheDir().toString();
        List<String> items = Arrays.asList(cacheDir.split("/"));
        String path = items.get(1) + "/" + items.get(2);

        String cmd = String.format("/system/bin/mount | grep '%s'", path);
        String[] command = { "/system/bin/sh", "-c", cmd };

        Process process = Runtime.getRuntime().exec(command, null, new File("/system/bin"));
        try {
            process.waitFor();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        String line;
        String output = "";
        BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
        while ((line = in.readLine()) != null) {
            output += line;
        }

        List<String> outputItems = Arrays.asList(output.split(" "));
        if (outputItems.size() >= 3) {
            if (outputItems.get(2).equals("vfat")) {
                return true;
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return false;
}

From source file:com.flipkart.flux.resource.StateMachineResourceTest.java

@AfterClass
public static void afterClass() {
    try {/*from w  w w  .j a v a  2 s .  com*/
        Thread.sleep(3000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:fi.jumi.test.AppRunner.java

private static void kill(Process process) {
    process.destroy();//w w  w .  ja v a 2s .com
    try {
        process.waitFor();
    } catch (InterruptedException e) {
        e.printStackTrace();
        Thread.currentThread().interrupt();
    }
}

From source file:org.ebayopensource.fidouafclient.curl.Curl.java

public static String getInSeparateThread(String url) {
    GetAsyncTask async = new GetAsyncTask();
    async.execute(url);/*from   w w w  .j  a va2s.  c o  m*/
    while (!async.isDone()) {
        try {
            Thread.sleep(1);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    return async.getResult();
}

From source file:org.ebayopensource.fidouafclient.curl.Curl.java

public static String postInSeparateThread(String url, String header, String data) {
    PostAsyncTask async = new PostAsyncTask();
    async.execute(url, header, data);/* w  w w .j a va 2  s  .co m*/
    while (!async.isDone()) {
        try {
            Thread.sleep(1);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    return async.getResult();
}

From source file:gov.nist.appvet.tool.synchtest.Service.java

private static boolean customExecute(StringBuffer output) {
    try {//  w  w  w. j av  a2 s .  c o m
        log.info("Executing sleep test");
        Thread.sleep(SLEEP_TIME);
        output.append("Android SynchTest Results: OK");
        log.info("Ending sleep test");
        return true;
    } catch (InterruptedException e) {
        e.printStackTrace();
        return false;
    }
}

From source file:com.solace.demos.cloudfoundry.scaling.aggregator.controller.ProducerThread.java

private static final long waitUntil(long targetNanoTime) {
    long curtime = System.nanoTime();
    long waittimeInMs = (targetNanoTime - curtime) / 1000000;
    if (waittimeInMs > 0) {
        try {/*from   w ww  .j  a  v  a 2  s.  c o  m*/
            Thread.sleep(waittimeInMs);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    return waittimeInMs;
}

From source file:org.aliuge.crawler.fetcher.Fetcher.java

public static synchronized void runProxyer() throws Exception {
    // ?ip?//  w w  w  .j  a  va  2 s. c om
    Thread t = new Thread(new Runnable() {
        @SuppressWarnings("null")
        @Override
        public void run() {
            int count = 0;
            @SuppressWarnings("unused")
            boolean flag_fetchProxyIps = false;
            while (proxyerisRuning) {
                try {
                    TimeUnit.SECONDS.sleep(5);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                try {
                    @SuppressWarnings("unused")
                    Iterable<String> it = null;
                    for (String ip : it = m.keySet()) {
                        int t = m.get(ip);

                        if (t > 10 && StringUtils.isNotBlank(ip)) {
                            m.remove(ip);
                            proxyIps.remove(ip);
                            slog.info("?ip" + ip);
                        }
                    }
                    if (proxyIps.size() < 30) {
                        slog.info("?ip?30??");
                        //proxyIps.addAll(ProxyIp.fetchProxyIps(true));
                        proxyIps.addAll(ProxyIp.fetchProxyIps(false));
                        m.clear();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                // 10???ip
                if (count == 10) {
                    storeProxyIp();
                    count = 0;
                } else {
                    count++;
                }
            }
            // ? ??ip
            storeProxyIp();

        }

    }, "?Ip");
    t.start();

}

From source file:com.ryebrye.releaser.weathersensors.BMP180Sensor.java

protected static void waitfor(long howMuch) {
    try {//from w w w .  j  a v  a2s.  c o m
        Thread.sleep(howMuch);
    } catch (InterruptedException ie) {
        ie.printStackTrace();
    }
}

From source file:net.mceoin.cominghome.api.NestUtil.java

public static String tellNestAwayStatus(String access_token, String structure_id, String away_status) {
    String result = tellNestAwayStatusCall(access_token, structure_id, away_status);

    if ((result.contains("Error:")) && (!result.contains("Unauthorized"))) {
        // Try again if it was an Error but not an Unauthorized
        try {/*from  ww  w  .  ja  v a2 s.  c  o  m*/
            Random randomGenerator = new Random();
            int seconds = 5 + randomGenerator.nextInt(10);
            log.info("retry in " + seconds + " seconds");
            Thread.sleep(seconds * 1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        result = tellNestAwayStatusCall(access_token, structure_id, away_status);
    }

    return result;
}