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

com.loadcoder.load.intensity.ThreadSynchronizer Maven / Gradle / Ivy

There is a newer version: 3.1.1
Show newest version
package com.loadcoder.load.intensity;

public class ThreadSynchronizer extends Thread {

	Thread current;

	int joined = 0;

	int amountToBeSynchronized = 0;

	public synchronized boolean syncMe() {
		joined++;
		if (joined >= amountToBeSynchronized) {
			this.interrupt();
			return false;
		} else {
			try {
				this.join();
				return true;
			} catch (InterruptedException e) {
				throw new RuntimeException(e);
			}
		}
	}

	public ThreadSynchronizer(Runnable runnable, int amountToBeSynchronized) {
		super(runnable);
		this.amountToBeSynchronized = amountToBeSynchronized;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy