Hello,
My purpose is to run 100 threads, which will be running php programs.
As long as these programs php are identicall there is no problem.
The problem is when there are 100 different programs. - Threads are still alive and never finish. The code looks like:

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class MyRunnableClass implements Runnable
{
public MyRunnableClass (String program)
{
inputToPhp[0]="php";
inputToPhp[1]="-r";
inputToPhp[2]=program;
}

	public void run()
	{

		try
		{ 	r = Runtime.getRuntime();
			p = r.exec(inputToPhp);
		}
		catch( IOException f)
		{
			System.err.println("IOException!");
			p.destroy();
		}

		try
		{p.waitFor();}
		catch( InterruptedException e )
		{p.destroy();}

        reader = new BufferedReader(new InputStreamReader(p.getInputStream()));

//...
//...
//...
}

	private BufferedReader reader;
	private String[] inputToPhp = new String[3];
	private Runtime r;
	private Process p;

}

public class Population
{
public static void main(String args[])
{

int POPULATION=100;
int delay = 1000;
int nMills= 10000;
int nTimes = nMills/delay;

String[] programs= {}; //...
			 //contains 100 different simple programs without errors
			 // for example "echo('something');"



MyRunnableClass[] r = new MyRunnableClass[POPULATION];
Thread[] php   = new Thread[POPULATION];

// here I'm starting all threads
for (int i=0;i<POPULATION;i++)
{

		r [i] = new MyRunnableClass(programs[i]);
		php[i]   = new Thread(r[i]);
		php[i].start();

}

// here I'm waiting 10 secunds
for(int k=0;k<nTimes;k++)
{
try
{
Thread.sleep(delay);

	      } catch (InterruptedException e) {}
}

// here I'm expecting that all threads are finished, but they aren't and still running...why ??
for (int i=0;i<POPULATION;i++)
{
if ( php[i].isAlive() )
{
php[i].interrupt();
System.out.println("Interrupted thread " + i );
}
}

}

}

Thanks, Pawel