Skip to content

Instantly share code, notes, and snippets.

@nitsanw
Created December 11, 2015 15:22
Show Gist options
  • Save nitsanw/3b39a4abc44c7475c90c to your computer and use it in GitHub Desktop.
Save nitsanw/3b39a4abc44c7475c90c to your computer and use it in GitHub Desktop.
@Param({ "0" })
int idleThreads;
Thread[] pool;
@Setup
public final void bakeACake() {
if (idleThreads != 0) {
pool = new Thread[idleThreads];
for (int i = 0; i < idleThreads; i++) {
pool[i] = new Thread(() -> {
parkDeep(256);
});
pool[i].setDaemon(true);
pool[i].start();
}
}
}
static void parkDeep(int i) {
if (i == 0) {
LockSupport.park();
} else {
parkDeep(i - 1);
}
}
@Override
protected Object safepointMethod() {
return ManagementFactory.getThreadMXBean().dumpAllThreads(false, false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment