Skip to content

Commit

Permalink
better example
Browse files Browse the repository at this point in the history
  • Loading branch information
mnadeem committed Apr 17, 2021
1 parent 6f29665 commit b9ce108
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/test/java/com/github/dexecutor/core/DexecutorTimeoutTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import static org.assertj.core.api.Assertions.assertThat;

import java.math.BigInteger;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -111,17 +112,30 @@ public Integer execute() {

if (id == 14) {
try {
TimeUnit.MILLISECONDS.sleep(100);
TimeUnit.MILLISECONDS.sleep(30);
System.out.println("Done " + id);
} catch (InterruptedException e) {
logger.error(this.toString(), e);
}
} else if (id == 11) {
BigInteger factValue = BigInteger.ONE;
long t1 = System.nanoTime();
for (int i = 2; i <= 8000; i++) {
if (Thread.currentThread().isInterrupted()) {
logger.warn("Task #{} Interrupted, returning.....", id);
break ;
}
factValue = factValue.multiply(BigInteger.valueOf(i));
}
long t2 = System.nanoTime();
logger.info("Service Time(ms)= {}", ((double) (t2 - t1) / 1000000));
} else {
try {
TimeUnit.MILLISECONDS.sleep(1);
} catch (InterruptedException e) {
logger.error(this.toString(), e);
}
}
}

return id;
}
Expand Down

0 comments on commit b9ce108

Please sign in to comment.