You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by sg...@apache.org on 2010/08/14 21:31:45 UTC
svn commit: r985572 -
/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java
Author: sgoeschl
Date: Sat Aug 14 19:31:45 2010
New Revision: 985572
URL: http://svn.apache.org/viewvc?rev=985572&view=rev
Log:
Storing the worker thread used for asynchronous in field and providing protected getter.
Modified:
commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java
Modified: commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java?rev=985572&r1=985571&r2=985572&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java (original)
+++ commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java Sat Aug 14 19:31:45 2010
@@ -63,6 +63,9 @@ public class DefaultExecutor implements
/** optional cleanup of started processes */
private ProcessDestroyer processDestroyer;
+ /** worker thread for asynchronous execution */
+ private Thread executorThread;
+
/**
* Default constructor creating a default <code>PumpStreamHandler</code>
* and sets the working directory of the subprocess to the current
@@ -178,11 +181,7 @@ public class DefaultExecutor implements
throw new IOException(workingDirectory + " doesn't exist.");
}
- new Thread() {
-
- /**
- * @see java.lang.Thread#run()
- */
+ executorThread = new Thread() {
public void run() {
int exitValue = Executor.INVALID_EXITVALUE;
try {
@@ -194,9 +193,10 @@ public class DefaultExecutor implements
handler.onProcessFailed(new ExecuteException("Execution failed", exitValue, e));
}
}
- }.start();
- }
+ };
+ getExecutorThread().start();
+ }
/** @see org.apache.commons.exec.Executor#setExitValue(int) */
public void setExitValue(final int value) {
@@ -255,6 +255,15 @@ public class DefaultExecutor implements
}
/**
+ * Get the worker thread being used for asynchronous execution.
+ *
+ * @return the worker thread
+ */
+ protected Thread getExecutorThread() {
+ return executorThread;
+ }
+
+ /**
* Close the streams belonging to the given Process. In the
* original implementation all exceptions were dropped which
* is probably not a good thing. On the other hand the signature