ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/extra166y/CommonOps.java
(Generate patch)

Comparing jsr166/src/extra166y/CommonOps.java (file contents):
Revision 1.1 by dl, Tue Jan 6 14:30:57 2009 UTC vs.
Revision 1.2 by dl, Mon Jan 12 17:16:36 2009 UTC

# Line 790 | Line 790 | public class CommonOps {
790      /**
791       * Returns a generator producing uniform random values between
792       * zero and one, with the same properties as {@link
793 <     * java.util.Random#nextDouble} but operating independently across
794 <     * ForkJoinWorkerThreads and usable only within forkjoin
795 <     * computations.
793 >     * java.util.Random#nextDouble}
794       */
795      public static DoubleGenerator doubleRandom() {
796          return DoubleRandomGenerator.generator;
# Line 801 | Line 799 | public class CommonOps {
799          static final DoubleRandomGenerator generator =
800              new DoubleRandomGenerator();
801          public double op() {
802 <            return ForkJoinWorkerThread.nextRandomDouble();
802 >            return ThreadLocalRandom.current().nextDouble();
803          }
804      }
805  
806      /**
807       * Returns a generator producing uniform random values between
808       * zero and the given bound, with the same properties as {@link
809 <     * java.util.Random#nextDouble} but operating independently across
812 <     * ForkJoinWorkerThreads and usable only within forkjoin
813 <     * computations.
809 >     * java.util.Random#nextDouble}.
810       * @param bound the upper bound (exclusive) of opd values
811       */
812      public static DoubleGenerator doubleRandom(double bound) {
# Line 820 | Line 816 | public class CommonOps {
816          final double bound;
817          DoubleBoundedRandomGenerator(double bound) { this.bound = bound; }
818          public double op() {
819 <            return ForkJoinWorkerThread.nextRandomDouble() * bound;
819 >            return ThreadLocalRandom.current().nextDouble() * bound;
820          }
821      }
822  
823      /**
824       * Returns a generator producing uniform random values between the
825 <     * given least value (inclusive) and bound (exclusive), operating
830 <     * independently across ForkJoinWorkerThreads and usable only
831 <     * within forkjoin computations.
825 >     * given least value (inclusive) and bound (exclusive)
826       * @param least the least value returned
827       * @param bound the upper bound (exclusive) of opd values
828       */
# Line 842 | Line 836 | public class CommonOps {
836              this.least = least; this.range = bound - least;
837          }
838          public double op() {
839 <            return ForkJoinWorkerThread.nextRandomDouble() * range + least;
839 >            return ThreadLocalRandom.current().nextDouble() * range + least;
840          }
841      }
842  
843      /**
844       * Returns a generator producing uniform random values with the
845 <     * same properties as {@link java.util.Random#nextLong} but
852 <     * operating independently across ForkJoinWorkerThreads and usable
853 <     * only within forkjoin computations.
845 >     * same properties as {@link java.util.Random#nextLong}
846       */
847      public static LongGenerator longRandom() {
848          return LongRandomGenerator.generator;
# Line 859 | Line 851 | public class CommonOps {
851          static final LongRandomGenerator generator =
852              new LongRandomGenerator();
853          public long op() {
854 <            return ForkJoinWorkerThread.nextRandomLong();
854 >            return ThreadLocalRandom.current().nextLong();
855          }
856      }
857  
858      /**
859       * Returns a generator producing uniform random values with the
860 <     * same properties as {@link java.util.Random#nextInt(int)} but
869 <     * operating independently across ForkJoinWorkerThreads and usable
870 <     * only within forkjoin computations.
860 >     * same properties as {@link java.util.Random#nextInt(int)}
861       * @param bound the upper bound (exclusive) of opd values
862       */
863      public static LongGenerator longRandom(long bound) {
# Line 879 | Line 869 | public class CommonOps {
869          final long bound;
870          LongBoundedRandomGenerator(long bound) { this.bound = bound; }
871          public long op() {
872 <            return ForkJoinWorkerThread.nextRandomLong(bound);
872 >            return ThreadLocalRandom.current().nextLong(bound);
873          }
874      }
875  
876      /**
877       * Returns a generator producing uniform random values between the
878 <     * given least value (inclusive) and bound (exclusive), operating
889 <     * independently across ForkJoinWorkerThreads and usable only
890 <     * within forkjoin computations.
878 >     * given least value (inclusive) and bound (exclusive).
879       * @param least the least value returned
880       * @param bound the upper bound (exclusive) of opd values
881       */
# Line 903 | Line 891 | public class CommonOps {
891              this.least = least; this.range = bound - least;
892          }
893          public long op() {
894 <            return ForkJoinWorkerThread.nextRandomLong(range) + least;
894 >            return ThreadLocalRandom.current().nextLong(range) + least;
895          }
896      }
897  
898      /**
899       * Returns a generator producing uniform random values with the
900 <     * same properties as {@link java.util.Random#nextInt} but
913 <     * operating independently across ForkJoinWorkerThreads and usable
914 <     * only within forkjoin computations.
900 >     * same properties as {@link java.util.Random#nextInt}
901       */
902      public static IntGenerator intRandom() {
903          return IntRandomGenerator.generator;
# Line 920 | Line 906 | public class CommonOps {
906          static final IntRandomGenerator generator =
907              new IntRandomGenerator();
908          public int op() {
909 <            return ForkJoinWorkerThread.nextRandomInt();
909 >            return ThreadLocalRandom.current().nextInt();
910          }
911      }
912  
913      /**
914       * Returns a generator producing uniform random values with the
915 <     * same properties as {@link java.util.Random#nextInt(int)} but
930 <     * operating independently across ForkJoinWorkerThreads and usable
931 <     * only within forkjoin computations.
915 >     * same properties as {@link java.util.Random#nextInt(int)}
916       * @param bound the upper bound (exclusive) of opd values
917       */
918      public static IntGenerator intRandom(int bound) {
# Line 940 | Line 924 | public class CommonOps {
924          final int bound;
925          IntBoundedRandomGenerator(int bound) { this.bound = bound; }
926          public int op() {
927 <            return ForkJoinWorkerThread.nextRandomInt(bound);
927 >            return ThreadLocalRandom.current().nextInt(bound);
928          }
929      }
930  
931      /**
932       * Returns a generator producing uniform random values between the
933 <     * given least value (inclusive) and bound (exclusive), operating
950 <     * independently across ForkJoinWorkerThreads and usable only
951 <     * within forkjoin computations.
933 >     * given least value (inclusive) and bound (exclusive)
934       * @param least the least value returned
935       * @param bound the upper bound (exclusive) of opd values
936       */
# Line 964 | Line 946 | public class CommonOps {
946              this.least = least; this.range = bound - least;
947          }
948          public int op() {
949 <            return ForkJoinWorkerThread.nextRandomInt(range) + least;
949 >            return ThreadLocalRandom.current().nextInt(range) + least;
950          }
951      }
952  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines