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

com.scudata.thread.Job Maven / Gradle / Ivy

Go to download

SPL(Structured Process Language) A programming language specially for structured data computing.

There is a newer version: 20241126
Show newest version
package com.scudata.thread;

import com.scudata.common.RQException;

/**
 * ??????󣬿????ύ??ThreadPool????JobThreadִ??
 * @author WangXiaoJun
 *
 */
public abstract class Job implements Runnable {
	private boolean isFinished; // ?????Ƿ??????
	private Throwable error; // ????ִ?й????е??쳣??Ϣ??û??????Ϊ??
	
	/**
	 * ?ȴ?????ִ????
	 */
	public final synchronized void join() {
		if (!isFinished) {
			try {
				wait();
			} catch (InterruptedException e) {
				// ide?????̣߳??˴??׳??쳣???ܵ???jvm????
				//throw new RQException(e);
			}
		}
		
		if (error != null) {
			if (error instanceof RQException) {
				throw (RQException)error;
			} else {
				throw new RQException(error);
			}
		}
	}

	void reset() {
		isFinished = false;
		error = null;
	}

	synchronized void finish() {
		isFinished = true;
		notify();
	}
	
	void setError(Throwable error) {
		this.error = error;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy