We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5e30e6c commit 35c30a2Copy full SHA for 35c30a2
1 file changed
highcpu/src/main/java/com/github/chrishantha/sample/highcpu/MathWorker.java
@@ -27,11 +27,13 @@ public MathWorker() {
27
28
@Override
29
public void run() {
30
+ BigDecimal bigDecimal = BigDecimal.ZERO;
31
while (true) {
- BigDecimal sum = BigDecimal.ZERO;
32
- for (int i = 0; i <= Integer.MAX_VALUE; i++) {
33
- double value = Math.atan(Math.sqrt(Math.pow(random.nextInt(10), random.nextDouble())));
34
- sum = sum.add(BigDecimal.valueOf(value));
+ double value = Math.atan(Math.sqrt(Math.pow(random.nextInt(10), random.nextDouble())));
+ if (random.nextInt(10) > 5) {
+ bigDecimal = bigDecimal.add(BigDecimal.valueOf(value));
35
+ } else {
36
+ bigDecimal = bigDecimal.subtract(BigDecimal.valueOf(value));
37
}
38
39
0 commit comments