All Downloads are FREE. Search and download functionalities are using the official Maven repository.

util.parallel.ParallelFuture Maven / Gradle / Ivy

There is a newer version: 11.4.6-RELEASE
Show newest version
package util.parallel;

import java.util.List;


/** 
 * Copyright (c) 2012-present Holger Schneider
 * All rights reserved.
 *
 * This source code is licensed under the MIT License (MIT) found in the
 * LICENSE file in the root directory of this source tree.
 *
 * 
 * @author hschneid
 *
 * @param 
 */
public abstract class ParallelFuture implements Runnable, Cloneable {

	private E o;
	private List list;
	
	public ParallelFuture() {}
	
	/**
	 * 
	 * @param o
	 * @return
	 */
	public abstract A run(E o);

	/*  
	 * (non-Javadoc)
	 * @see java.lang.Runnable#run()
	 */
	@Override
	public void run() {
		try {
			if(o != null)
				list.add(run(o));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * 
	 * @param o
	 * @param list
	 */
	void set(E o, List list) {
		this.o = o;
		this.list = list;
	}

	/**
	 * 
	 * @return
	 * @throws CloneNotSupportedException
	 */
	@SuppressWarnings("unchecked")
	public ParallelFuture copy() throws CloneNotSupportedException {
		return (ParallelFuture) super.clone();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy