コード例 #1
1
 public static void main(String[] args) throws InterruptedException {
   Thread thread = new Thread(new MyRunnable());
   thread.start();
   Thread.sleep(1000);
   thread.destroy();
   System.out.println("Existing application");
 }
コード例 #2
1
ファイル: SSHExecute.java プロジェクト: nterry/jclouds-1
  /** @throws TimeoutException */
  @SuppressWarnings("deprecation")
  private void waitFor(final ChannelExec channel) throws TimeoutException {
    // wait for it to finish
    Thread thread =
        new Thread() {
          public void run() {
            while (!channel.isClosed()) {
              try {
                sleep(RETRY_INTERVAL);
              } catch (InterruptedException e) {
                // ignored
              }
            }
          }
        };

    thread.start();
    try {
      thread.join(maxwait);
    } catch (InterruptedException e) {
      // ignored
    }

    if (thread.isAlive()) {
      thread.destroy();
      throw new TimeoutException("command still running");
    }
  }
コード例 #3
1
 @Override
 public void destroy() {
   // TODO Auto-generated method stub
   super.destroy();
   this.interrupt();
   // null
 }