ProcessMonitor.java :  » Net » Terracotta » com » tc » Java Open Source

Java Open Source » Net » Terracotta 
Terracotta » com » tc » ProcessMonitor.java
/*
 * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice.  All rights reserved.
 */
package com.tc;

/**
 * This is for monitoring a process where something else is draining the output and
 * error streams, such as a ProcessWaiter or a ProcessOutputView. 
 */

public class ProcessMonitor extends Thread {
  private Process                    m_process;
  private ProcessTerminationListener m_terminationListener;
  
  public ProcessMonitor(Process process,
                        ProcessTerminationListener terminationListener)
  {
    super();

    m_process             = process;
    m_terminationListener = terminationListener;
    
    start();
  }

  public void run() {
    while(true) {
      try {
        m_process.waitFor();
        m_terminationListener.processTerminated(m_process.exitValue());
        return;
      } catch(InterruptedException ie) {/**/}
    }
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.