Skip to content

Commit

Permalink
Prevent divide by 0 (#319)
Browse files Browse the repository at this point in the history
* Prevent divide by 0

Added in a ternary operation so that if it evaluates to 0 it will become 1 instead.

* Change ternary to Math.max

Co-authored-by: DJtheRedstoner <[email protected]>

---------

Co-authored-by: DJtheRedstoner <[email protected]>
  • Loading branch information
Phoenix-Starlight and DJtheRedstoner authored Jun 15, 2024
1 parent 12a1ec5 commit b6219f1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/enchcracker/cracker/JavaSingleSeedCracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void resetCracker() {
@Override
public void firstInput(int bookshelves, int slot1, int slot2, int slot3) {
abortRequested.set(false);
final int threadCount = Runtime.getRuntime().availableProcessors() - 1; // always leave one for OS
final int threadCount = Math.max(Runtime.getRuntime().availableProcessors() - 1, 1); // always leave one for OS but ensure at least 1 processor is used
final int blockSize = Integer.MAX_VALUE / 20 / threadCount - 1;
final AtomicInteger seed = new AtomicInteger(Integer.MIN_VALUE);
ArrayList<Thread> threads = new ArrayList<>();
Expand Down

0 comments on commit b6219f1

Please sign in to comment.