KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > process > LinkedJavaProcessTestMain5


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.process;
5
6 import java.io.File JavaDoc;
7 import java.io.FileOutputStream JavaDoc;
8
9 /**
10  * A test program for {@link LinkedJavaProcessTest}that, in turn, spawns some of its own children as linked processes.
11  * The test then kills this process, and makes sure that the children die, too.
12  */

13 public class LinkedJavaProcessTestMain5 {
14
15   public static void main(String JavaDoc[] args) throws Exception JavaDoc {
16     File JavaDoc destFile = new File JavaDoc(args[0]);
17     boolean spawnChildren = new Boolean JavaDoc(args[1]).booleanValue();
18
19     if (spawnChildren) {
20       LinkedJavaProcess child1 = new LinkedJavaProcess(LinkedJavaProcessTestMain5.class.getName(),
21                                                        new String JavaDoc[] { args[0] + "-child-1", "false" });
22       LinkedJavaProcess child2 = new LinkedJavaProcess(LinkedJavaProcessTestMain5.class.getName(),
23                                                        new String JavaDoc[] { args[0] + "-child-2", "false" });
24       
25       child1.start();
26       child2.start();
27     }
28     
29     while (true) {
30       FileOutputStream JavaDoc out = new FileOutputStream JavaDoc(destFile, true);
31       out.write("DATA: Just a line of text.\n".getBytes());
32       out.flush();
33       out.close();
34       
35       Thread.sleep(100);
36     }
37   }
38
39 }
40
Popular Tags