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

com.firefly.core.AbstractLifeCycle Maven / Gradle / Ivy

There is a newer version: 4.0.3.2
Show newest version
package com.firefly.core;

public abstract class AbstractLifeCycle implements LifeCycle {
	
	protected volatile boolean start;

	@Override
	public boolean isStarted() {
		return start;
	}

	@Override
	public boolean isStopped() {
		return !start;
	}
	
	@Override
	public void start() {
		if (isStarted())
			return;

		synchronized (this) {
			if (isStarted())
				return;
			
			init();
			start = true;
		}
	}

	@Override
	public void stop() {
		if (isStopped())
			return;

		synchronized (this) {
			if (isStopped())
				return;
			
			destroy();
			start = false;
		}
	}
	
	abstract protected void init();
	
	abstract protected void destroy();

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy