mirror of
https://github.com/async-profiler/async-profiler.git
synced 2026-04-28 02:53:00 +00:00
27 lines
660 B
Java
27 lines
660 B
Java
import java.util.Random;
|
|
|
|
public class AllocatingTarget implements Runnable {
|
|
public static volatile Object sink;
|
|
|
|
public static void main(String[] args) {
|
|
new Thread(new AllocatingTarget(), "AllocThread-1").start();
|
|
new Thread(new AllocatingTarget(), "AllocThread-2").start();
|
|
}
|
|
|
|
@Override
|
|
public void run() {
|
|
Random random = new Random();
|
|
while (true) {
|
|
allocate(random);
|
|
}
|
|
}
|
|
|
|
private static void allocate(Random random) {
|
|
if (random.nextBoolean()) {
|
|
sink = new int[128 * 1000];
|
|
} else {
|
|
sink = new Integer[128 * 1000];
|
|
}
|
|
}
|
|
}
|