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

aQute.bnd.repository.maven.provider.WhileYouWereBusy Maven / Gradle / Ivy

There is a newer version: 7.1.0
Show newest version
package aQute.bnd.repository.maven.provider;

public abstract class WhileYouWereBusy {
	boolean	busy;
	boolean	request;

	public void doAction() throws Exception {
		synchronized (this) {
			request = true;
			if (busy)
				return;
			busy = true;
			request = false;
		}
		while (true)
			try {
				run();
			} finally {
				synchronized (this) {
					if (request) {
						while (request) {
							Thread.sleep(100); // coalesce
							request = false;
						}
					} else {
						busy = false;
						return;
					}
				}
			}
	}

	public abstract void run() throws Exception;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy