Example usage for java.lang InterruptedException toString

List of usage examples for java.lang InterruptedException toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:ffx.numerics.fft.RowMajorComplex3DCuda.java

/**
 * Blocking free method./*from   w w w  . j  a  va 2 s.c  o  m*/
 *
 * @return A status flag (0 for success, -1 for failure).
 */
public int free() {
    if (dead || doConvolution) {
        return -1;
    }

    free = true;

    // Notify the CUDA thread and then block until it notifies us back.
    synchronized (this) {
        notify();
        while (!dead) {
            try {
                wait();
            } catch (InterruptedException e) {
                logger.severe(e.toString());
            }
        }
    }

    return 0;
}

From source file:ffx.numerics.fft.RowMajorComplex3DCuda.java

/**
 * Blocking convolution method.//from w ww  .ja va2  s .c  om
 *
 * @param data an array of double.
 * @return A status flag (0 for success, -1 for failure).
 */
public int convolution(double data[]) {
    // This would be a programming error.
    if (dead || doConvolution) {
        return -1;
    }

    this.data = data;
    doConvolution = true;

    // Notify the CUDA thread and then block until it notifies us back.
    synchronized (this) {
        notify();
        while (doConvolution) {
            try {
                wait();
            } catch (InterruptedException e) {
                logger.severe(e.toString());
            }
        }
    }

    return 0;
}

From source file:uk.co.modularaudio.service.apprendering.impl.HotspotRenderingAppStructure.java

@Override
public void stopHotspotLooping() {
    // Let it exit gracefully
    try {//from w  w  w. jav  a2s.  c  o m
        hotspotClockSourceThread.halt();
        Thread.sleep(200);
    } catch (final InterruptedException ie) {
    }
    if (hotspotClockSourceThread.isAlive()) {
        hotspotClockSourceThread.forceHalt();
    }
    try {
        hotspotClockSourceThread.join();
    } catch (final InterruptedException ie) {
        final String msg = "Interrupted waiting for join to hotspot thread: " + ie.toString();
        log.error(msg, ie);
    }
    hotspotClockSourceThread = null;
}

From source file:com.example.guan.webrtc_android_7.common.WebSocketClient.java

public void disconnect(boolean waitForComplete) {
    checkIfCalledOnValidThread();//ww w . j a  v  a 2 s. com
    Log.d(TAG, "Disconnect WebSocket. State: " + state);
    if (state == WebSocketConnectionState.REGISTERED) {
        // Send "bye" to WebSocket server.
        //send("{\"type\": \"bye\"}");

        state = WebSocketConnectionState.CONNECTED;
        // Send http DELETE to http WebSocket server.
        sendWSSMessage("DELETE", "");
    }
    // Close WebSocket in CONNECTED or ERROR states only.
    if (state == WebSocketConnectionState.CONNECTED || state == WebSocketConnectionState.ERROR) {
        ws.disconnect();
        state = WebSocketConnectionState.CLOSED;

        // Wait for websocket close event to prevent websocket library from
        // sending any pending messages to deleted looper thread.
        if (waitForComplete) {
            synchronized (closeEventLock) {
                while (!closeEvent) {
                    try {
                        closeEventLock.wait(CLOSE_TIMEOUT);
                        break;
                    } catch (InterruptedException e) {
                        Log.e(TAG, "Wait error: " + e.toString());
                    }
                }
            }
        }
    }
    Log.e(TAG, "Disconnecting WebSocket done.");
}

From source file:de.lespace.apprtc.WebSocketChannelClient.java

public void disconnect(boolean waitForComplete) {
    checkIfCalledOnValidThread();//from  w  ww .j  ava  2s  . c o m
    Log.d(TAG, "Disonnect WebSocket. State: " + state);
    if (state == WebSocketConnectionState.REGISTERED) {
        // Send "bye" to WebSocket server.
        send("{\"id\": \"stop\"}");
        state = WebSocketConnectionState.CONNECTED;
    }
    // Close WebSocket ERROR states only.
    if (state == WebSocketConnectionState.ERROR) {
        ws.disconnect();
        state = WebSocketConnectionState.CLOSED;

        // Wait for websocket close event to prevent websocket library from
        // sending any pending messages to deleted looper thread.
        if (waitForComplete) {
            synchronized (closeEventLock) {
                while (!closeEvent) {
                    try {
                        closeEventLock.wait(CLOSE_TIMEOUT);
                        break;
                    } catch (InterruptedException e) {
                        Log.e(TAG, "Wait error: " + e.toString());
                    }
                }
            }
        }
    }
    Log.d(TAG, "Disonnecting WebSocket done.");
}

From source file:org.zaproxy.zapmavenplugin.ProcessZAP.java

/**
 * Search for all links and pages on the URL
 *
 * @param url the to investigate URL/*  w  w  w  .ja va2  s .  co m*/
 * @throws ClientApiException
 */
private void spiderURL(String url) throws ClientApiException {
    zapClientAPI.spider.scan(url);

    while (statusToInt(zapClientAPI.spider.status()) < 100) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            getLog().error(e.toString());
        }
    }
}

From source file:org.zaproxy.zapmavenplugin.ProcessZAP.java

/**
 * Scan all pages found at url//from  www .  jav  a2 s . c  om
 *
 * @param url the url to scan
 * @throws ClientApiException
 */
private void scanURL(String url) throws ClientApiException {
    zapClientAPI.ascan.scan(url, "true", "false");

    while (statusToInt(zapClientAPI.ascan.status()) < 100) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            getLog().error(e.toString());
        }
    }
}

From source file:org.apache.hadoop.util.SSHRemoteExecution.java

/**
 * Execute command at remote host under given user
 * @param remoteHostName remote host name
 * @param user is the name of the user to be login under;
 *   current user will be used if this is set to <code>null</code>
 * @param command to be executed remotely
 * @param identityFile is the name of alternative identity file; default
 *   is ~user/.ssh/id_dsa//from  www.  ja va2  s .  c o  m
 * @param portNumber remote SSH daemon port number, default is 22
 * @throws Exception in case of errors
 */
public void executeCommand(String remoteHostName, String user, String command, String identityFile,
        int portNumber) throws Exception {
    commandString = command;
    String sessionUser = System.getProperty("user.name");
    String userHome = System.getProperty("user.home");
    if (user != null) {
        sessionUser = user;
        userHome = getHomeDir() + FS + user;
    }
    String dotSSHDir = userHome + FS + ".ssh";
    String sessionIdentity = dotSSHDir + FS + DEFAULT_IDENTITY;
    if (identityFile != null) {
        sessionIdentity = identityFile;
    }

    JSch jsch = new JSch();

    Session session = jsch.getSession(sessionUser, remoteHostName, portNumber);
    jsch.setKnownHosts(dotSSHDir + FS + DEFAULT_KNOWNHOSTS);
    jsch.addIdentity(sessionIdentity);

    Properties config = new Properties();
    config.put("StrictHostKeyChecking", "no");
    session.setConfig(config);

    session.connect(30000); // making a connection with timeout.

    Channel channel = session.openChannel("exec");
    ((ChannelExec) channel).setCommand(command);
    channel.setInputStream(null);

    final BufferedReader errReader = new BufferedReader(
            new InputStreamReader(((ChannelExec) channel).getErrStream()));
    BufferedReader inReader = new BufferedReader(new InputStreamReader(channel.getInputStream()));

    channel.connect();
    Thread errorThread = new Thread() {
        @Override
        public void run() {
            try {
                String line = errReader.readLine();
                while ((line != null) && !isInterrupted()) {
                    errorMessage.append(line);
                    errorMessage.append(LS);
                    line = errReader.readLine();
                }
            } catch (IOException ioe) {
                LOG.warn("Error reading the error stream", ioe);
            }
        }
    };

    try {
        errorThread.start();
    } catch (IllegalStateException e) {
        LOG.debug(e);
    }
    try {
        parseExecResult(inReader);
        String line = inReader.readLine();
        while (line != null) {
            line = inReader.readLine();
        }

        if (channel.isClosed()) {
            exitCode = channel.getExitStatus();
            LOG.debug("exit-status: " + exitCode);
        }
        try {
            // make sure that the error thread exits
            errorThread.join();
        } catch (InterruptedException ie) {
            LOG.warn("Interrupted while reading the error stream", ie);
        }
    } catch (Exception ie) {
        throw new IOException(ie.toString());
    } finally {
        try {
            inReader.close();
        } catch (IOException ioe) {
            LOG.warn("Error while closing the input stream", ioe);
        }
        try {
            errReader.close();
        } catch (IOException ioe) {
            LOG.warn("Error while closing the error stream", ioe);
        }
        channel.disconnect();
        session.disconnect();
    }
}

From source file:org.owasp.ProcessMojo.java

/**
 * Search for all links and pages on the URL
 *
 * @param url the to investigate URL/*ww w  . j a v a 2s . c o  m*/
 * @throws ClientApiException
 */
private void spiderURL(String url) throws ClientApiException {
    zapClientAPI.spider.scan(apiKEY, url, "10", "");

    while (statusToInt(zapClientAPI.spider.status("scanid")) < 100) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            getLog().error(e.toString());
        }
    }
}

From source file:org.cryptable.zap.mavenplugin.ProcessMojo.java

/**
 * Search for all links and pages on the URL
 *
 * @param url the to investigate URL//  w  w w  .ja v a2  s  . co m
 * @throws ClientApiException
 */
private void spiderURL(String url) throws ClientApiException {
    zapClientAPI.spider.scan(apiKEY, url, "10", "", "");

    while (statusToInt(zapClientAPI.spider.status("scanid")) < 100) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            getLog().error(e.toString());
        }
    }
}