com.loadcoder.load.intensity.ThreadSynchronizer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of loadcoder-core Show documentation
Show all versions of loadcoder-core Show documentation
This project contains the core features in Loadcoder
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;
}
}