this.maxThreads = 5;
}
private void executeParallel(Vector tasks)
{
ThreadPool pool = new ThreadPool(maxThreads);
Enumeration e = tasks.elements();
Runnable r = null;
Vector threads = new Vector();
// start each task in it's own thread, using the
// pool to ensure that we don't exceed the maximum
// amount of threads
while (e.hasMoreElements())
{
// Create the Runnable object
final Task task = (Task)e.nextElement();
r = new Runnable()
{
public void run()
{
task.execute();
}
};
// Get a thread, and start the task.
// If there is no thread available, this will
// block until one becomes available
try
{
ThreadPoolThread tpt = pool.borrowThread();
tpt.setRunnable(r);
tpt.start();
threads.addElement(tpt);
}
catch (Exception ex)