-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.java
More file actions
20 lines (17 loc) · 686 Bytes
/
App.java
File metadata and controls
20 lines (17 loc) · 686 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class App {
public static final int NUM_TESTS = 6000; // ~30 mins
public static void main(String[] args) throws Exception {
int numberOfProcessors = Runtime.getRuntime().availableProcessors();
for (int i = 0; i < numberOfProcessors; i++)
new Thread(() -> simulateWork()).start();
}
private static void simulateWork() {
for (int i = 0; i < NUM_TESTS; i++)
spin(500);
}
private static void spin(int milliseconds) {
long sleepTime = milliseconds * 1000000L; // convert to nanoseconds
long startTime = System.nanoTime();
while ((System.nanoTime() - startTime) < sleepTime) {}
}
}