/*
 *  Copyright 2011 Eric F. Savage, code@efsavage.com
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
package com.ajah.thread.gang;

import java.util.ArrayList;
import java.util.List;

/**
 * @author <a href="http://efsavage.com">Eric F. Savage</a>, <a
 *         href="mailto:code@efsavage.com">code@efsavage.com</a>.
 * 
 */
public class SimpleWorkerGang {

	private List<Worker<?>> workers = new ArrayList<Worker<?>>();

	private boolean autoStart;

	/**
	 * Invokes go on all workers in this gang. This isn't necessary if autoStart
	 * is true.
	 */
	public void go() {
		for (Worker<?> worker : this.workers) {
			worker.go();
		}
	}

	/**
	 * Adds a worker to this gang.
	 * 
	 * @param worker
	 *            The worker to add to the gang. If autostart is active it will
	 *            begin execution immediately.
	 */
	public void add(Worker<?> worker) {
		this.workers.add(worker);
		if (this.autoStart) {
			worker.go();
		}
	}

}

@@ -980,16 +980,96 @@
 Start;%0A%0A
+%09public SimpleWorkerGang(boolean autoStart) %7B%0A%09%09this.autoStart = autoStart;%0A%09%7D%0A%0A
 %09/**%0A%09 *
@@ -1547,9 +1547,8 @@
 %09%7D%0A%09%7D%0A%0A%7D
-%0A

add autostart constructor