This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-daemon.git
The following commit(s) were added to refs/heads/master by this push:
new e82793b Simplify obtaining the size of the process list
e82793b is described below
commit e82793b6cbf9e11af489c10b2616a2a702896ec3
Author: Mark Thomas <[email protected]>
AuthorDate: Thu May 2 10:31:37 2019 +0100
Simplify obtaining the size of the process list
---
src/samples/AloneService.java | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/src/samples/AloneService.java b/src/samples/AloneService.java
index 16d3e62..a3c4c67 100644
--- a/src/samples/AloneService.java
+++ b/src/samples/AloneService.java
@@ -57,23 +57,18 @@ public class AloneService {
// XXX: Should we print something?
}
/* create an array to store the processes */
- int i=0;
- for (Enumeration e = prop.keys(); e.hasMoreElements() ;) {
- e.nextElement();
- i++;
- }
- System.err.println("ServiceDaemon: init for " + i + " processes");
- proc = new Process[i];
- readout = new ServiceDaemonReadThread[i];
- readerr = new ServiceDaemonReadThread[i];
- for (i=0;i<proc.length;i++) {
+ int processCount = prop.size();
+ System.err.println("ServiceDaemon: init for " + processCount + "
processes");
+ proc = new Process[processCount];
+ readout = new ServiceDaemonReadThread[processCount];
+ readerr = new ServiceDaemonReadThread[processCount];
+ for (int i = 0 ; i < processCount; i++) {
proc[i] = null;
readout[i] = null;
readerr[i] = null;
}
System.err.println("ServiceDaemon: init done ");
-
}
public void start() {