diff --git a/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorWithExecutor.java b/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorWithExecutor.java index 5022746f917..928deb352c8 100644 --- a/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorWithExecutor.java +++ b/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorWithExecutor.java @@ -180,7 +180,7 @@ public class DataGeneratorWithExecutor implements IDataGenerator { public DataGeneratorWithExecutor(DsfExecutor executor) { // Create the executor fExecutor = executor; - + final Random rand = new Random(); // Schedule a runnable to make the random changes. fExecutor.scheduleAtFixedRate( new DsfRunnable() { @@ -188,7 +188,7 @@ public class DataGeneratorWithExecutor implements IDataGenerator { randomChanges(); } }, - new Random().nextInt() % RANDOM_CHANGE_INTERVAL, + rand.nextInt(RANDOM_CHANGE_INTERVAL), RANDOM_CHANGE_INTERVAL, //Add a 10% variance to the interval. TimeUnit.MILLISECONDS); } @@ -409,8 +409,7 @@ public class DataGeneratorWithExecutor implements IDataGenerator { private void randomCountReset() { // Calculate the new count. Random random = new java.util.Random(); - fCount = MIN_COUNT + - Math.abs(random.nextInt()) % (MAX_COUNT - MIN_COUNT); + fCount = MIN_COUNT + random.nextInt(MAX_COUNT - MIN_COUNT); // Reset the changed values. fChangedValues.clear(); @@ -435,8 +434,8 @@ public class DataGeneratorWithExecutor implements IDataGenerator { Random random = new java.util.Random(); Map changed = new HashMap(); for (int i = 0; i < fCount * RANDOM_CHANGE_SET_PERCENTAGE / 100; i++) { - int randomIndex = Math.abs(random.nextInt()) % fCount; - int randomValue = Math.abs(random.nextInt()) % fCount; + int randomIndex = random.nextInt(fCount); + int randomValue = random.nextInt(fCount); changed.put(randomIndex, randomValue); } diff --git a/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorWithThread.java b/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorWithThread.java index 3b4a909e884..0fbde0fa87e 100644 --- a/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorWithThread.java +++ b/dsf/org.eclipse.cdt.examples.dsf/src_preprocess/org/eclipse/cdt/examples/dsf/dataviewer/DataGeneratorWithThread.java @@ -222,7 +222,7 @@ public class DataGeneratorWithThread extends Thread private void randomCountReset() { // Calculate the new count. Random random = new java.util.Random(); - fCount = MIN_COUNT + Math.abs(random.nextInt()) % (MAX_COUNT - MIN_COUNT); + fCount = MIN_COUNT + random.nextInt(MAX_COUNT - MIN_COUNT); // Reset the changed values. fChangedValues.clear(); @@ -238,8 +238,8 @@ public class DataGeneratorWithThread extends Thread Random random = new java.util.Random(); Map changed = new HashMap(); for (int i = 0; i < fCount * RANDOM_CHANGE_SET_PERCENTAGE / 100; i++) { - int randomIndex = Math.abs(random.nextInt()) % fCount; - int randomValue = Math.abs(random.nextInt()) % fCount; + int randomIndex = random.nextInt(fCount); + int randomValue = random.nextInt(fCount); changed.put(randomIndex, randomValue); }