Created
December 11, 2015 15:22
-
-
Save nitsanw/3b39a4abc44c7475c90c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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